10000 [3.10] gh-101936: Update the default value of fp from io.StringIO to … · python/cpython@0f28af5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f28af5

Browse files
[3.10] gh-101936: Update the default value of fp from io.StringIO to io.BytesIO (gh-102100) (#102118)
gh-101936: Update the default value of fp from io.StringIO to io.BytesIO (gh-102100) (cherry picked from commit 0d4c7fc) Co-authored-by: Long Vo <long.vo@linecorp.com>
1 parent 3e9fb1a commit 0f28af5

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

Lib/test/test_urllib2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,7 @@ def test_HTTPError_interface(self):
18261826
def test_gh_98778(self):
18271827
x = urllib.error.HTTPError("url", 405, "METHOD NOT ALLOWED", None, None)
18281828
self.assertEqual(getattr(x, "__notes__", ()), ())
1829+
self.assertIsInstance(x.fp.read(), bytes)
18291830

18301831
def test_parse_proxy(self):
18311832
parse_proxy_test_cases = [

Lib/urllib/error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, url, code, msg, hdrs, fp):
4343
self.fp = fp
4444
self.filename = url
4545
if fp is None:
46-
fp = io.StringIO()
46+
fp = io.BytesIO()
4747
self.__super_init(fp, hdrs, url, code)
4848

4949
def __str__(self):

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,7 @@ Kurt Vile
18671867
Norman Vine
18681868
Pauli Virtanen
18691869
Frank Visser
1870+
Long Vo
18701871
Johannes Vogel
18711872
Michael Vogt
18721873
Radu Voicilas
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The default value of ``fp`` becomes :class:`io.BytesIO` if :exc:`~urllib.error.HTTPError`
2+
is initialized without a designated ``fp`` parameter. Patch by Long Vo.

0 commit comments

Comments
 (0)
0