Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-101936: Update the default value of fp from io.StringIO to io.BytesIO #102100

Merged
merged 7 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/urllib/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, url, code, msg, hdrs, fp):
self.fp = fp
self.filename = url
if fp is None:
fp = io.StringIO()
fp = io.BytesIO()
self.__super_init(fp, hdrs, url, code)

def __str__(self):
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,7 @@ Kurt Vile
Norman Vine
Pauli Virtanen
Frank Visser
Long Vo
Johannes Vogel
Michael Vogt
Radu Voicilas
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HTTPError fp.read returns string instead of bytes
Copy link
Member

@corona10 corona10 Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value of ``fp`` becomes :class:`io.BytesIO` if :exc:`~urllib.error.HTTPError` is initialized without a designated `fp` parameter. Patch by Long Vo.