Skip to content

gh-74668: Fix support of bytes in urllib.parse.parse_qsl() #115771

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

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Feb 21, 2024

urllib.parse functions parse_qs() and parse_qsl() now support bytes arguments containing raw and percent-encoded non-ASCII data.

urllib.parse functions parse_qs() and parse_qsl() now support bytes
arguments containing raw and percent-encoded non-ASCII data.
@serhiy-storchaka serhiy-storchaka force-pushed the urlparse-parse_qsl-nonascii-bytes branch from f6e343d to cdd796a Compare February 21, 2024 16:03
@serhiy-storchaka serhiy-storchaka changed the title gh-93757: Fix support of bytes in urllib.parse.parse_qsl() gh-74668: Fix support of bytes in urllib.parse.parse_qsl() Feb 21, 2024
@serhiy-storchaka serhiy-storchaka merged commit bdba8ef into python:main Mar 5, 2024
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 5, 2024
…honGH-115771)

urllib.parse functions parse_qs() and parse_qsl() now support bytes
arguments containing raw and percent-encoded non-ASCII data.
(cherry picked from commit bdba8ef)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Mar 5, 2024

GH-116366 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 5, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 5, 2024
…honGH-115771)

urllib.parse functions parse_qs() and parse_qsl() now support bytes
arguments containing raw and percent-encoded non-ASCII data.
(cherry picked from commit bdba8ef)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Mar 5, 2024

GH-116367 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Mar 5, 2024
serhiy-storchaka added a commit that referenced this pull request Mar 5, 2024
…-115771) (GH-116366)

urllib.parse functions parse_qs() and parse_qsl() now support bytes
arguments containing raw and percent-encoded non-ASCII data.
(cherry picked from commit bdba8ef)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Mar 5, 2024
…-115771) (GH-116367)

urllib.parse functions parse_qs() and parse_qsl() now support bytes
arguments containing raw and percent-encoded non-ASCII data.
(cherry picked from commit bdba8ef)

Co-authored-by: Serhiy Storchaka <[email protected]>
@msullivan
Copy link
Contributor

This PR actually causes a probably accidental change in some currently working behavior. Previously:

import urllib.parse
>>> urllib.parse.parse_qsl(None)
[]

but now it raises TypeError: cannot convert 'NoneType' object to bytes.

I think it's obviously pretty debatable whether the old behavior was desirable but there is popular code in the wild that depends on it: https://github.com/encode/httpx/blob/7df47ce4d93a06f2c3310cd692b4c2336d7663ba/httpx/_urls.py#L431-L433.

(I stumbled across this when one of my colleagues was accidentally using a current dev branch of 3.11 and started getting mysterious errors from inside the bowels of the httpx client.)

@serhiy-storchaka serhiy-storchaka deleted the urlparse-parse_qsl-nonascii-bytes branch March 13, 2024 20:53
@serhiy-storchaka
Copy link
Member Author

Thank you for your report @msullivan. Could you please open a new issue?

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
…honGH-115771)

urllib.parse functions parse_qs() and parse_qsl() now support bytes
arguments containing raw and percent-encoded non-ASCII data.
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…honGH-115771)

urllib.parse functions parse_qs() and parse_qsl() now support bytes
arguments containing raw and percent-encoded non-ASCII data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants