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

bpo-38567: Handle bytes as input to urllib.parse.unquote_plus #16903

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

stein-k
Copy link
Contributor

@stein-k stein-k commented Oct 23, 2019

Handle bytes as input to unquote_plus

https://bugs.python.org/issue38567

@@ -734,6 +734,10 @@ def unquote_plus(string, encoding='utf-8', errors='replace'):

unquote_plus('%7e/abc+def') -> '~/abc def'
"""
if isinstance(string, bytes):
Copy link
Contributor

@eamanu eamanu Oct 24, 2019

Choose a reason for hiding this comment

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

according to the documentation https://docs.python.org/3/library/urllib.parse.html?highlight=urllib#urllib.parse.unquote_plus string must be a str type.

If you need parse bytes you must use unquote_to_bytes. IMO here you need prove if
string is a str

if !isinstance(string, str):
    raise TypeError ('a str object is required')

Copy link
Contributor Author

@stein-k stein-k Nov 1, 2019

Choose a reason for hiding this comment

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

I think handling both bytes and str would make it more like unquote in 3.9 (https://docs.python.org/3.9/library/urllib.parse.html?highlight=urllib#urllib.parse.unquote).

I would expect them to behave the same and accept the same types.

@csabella csabella requested a review from orsenthil Jan 10, 2020
@stein-k stein-k requested a review from taleinat Jan 31, 2020
@stein-k
Copy link
Contributor Author

stein-k commented Jan 31, 2020

I hope the comments I made to the proposed changes could be reviewed. The changes would make the urllib.parse API more consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants