gh-116764: Fix regressions in urllib.parse.parse_qsl() (GH-116801)

* Restore support of None and other false values.
* Raise TypeError for non-zero integers and non-empty sequences.

The regressions were introduced in gh-74668
(bdba8ef42b).
This commit is contained in:
Serhiy Storchaka 2024-03-16 12:36:05 +02:00 committed by GitHub
parent 269051d20e
commit 1069a462f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 1 deletions

View file

@ -773,7 +773,11 @@ def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
def _unquote(s):
return unquote_plus(s, encoding=encoding, errors=errors)
else:
qs = bytes(qs)
if not qs:
return []
# Use memoryview() to reject integers and iterables,
# acceptable by the bytes constructor.
qs = bytes(memoryview(qs))
if isinstance(separator, str):
separator = bytes(separator, 'ascii')
eq = b'='