Skip to content
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
Prev Previous commit
Next Next commit
NEWS entry, keep old var name for a smaller diff.
  • Loading branch information
gpshead committed Sep 16, 2022
commit 4ffac18d4e8ce373ad052aa36c412cc6dda172d0
11 changes: 6 additions & 5 deletions Lib/urllib/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def _unquote_impl(string: bytes | bytearray | str) -> bytes | bytearray:
if len(bits) == 1:
return string
res = bytearray(bits[0])
add_data = res.extend
append = res.extend
# Delay the initialization of the table to not waste memory
# if the function is never called
global _hextobyte
Expand All @@ -624,11 +624,11 @@ def _unquote_impl(string: bytes | bytearray | str) -> bytes | bytearray:
for a in _hexdig for b in _hexdig}
for item in bits[1:]:
try:
add_data(_hextobyte[item[:2]])
add_data(item[2:])
append(_hextobyte[item[:2]])
append(item[2:])
except KeyError:
add_data(b'%')
add_data(item)
append(b'%')
append(item)
return res

_asciire = re.compile('([\x00-\x7f]+)')
Expand Down Expand Up @@ -665,6 +665,7 @@ def unquote(string, encoding='utf-8', errors='replace'):
errors = 'replace'
return ''.join(_generate_unquoted_parts(string, encoding, errors))


def parse_qs(qs, keep_blank_values=False, strict_parsing=False,
encoding='utf-8', errors='replace', max_num_fields=None, separator='&'):
"""Parse a query given as a string argument.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Reduced the memory usage of :func:`urllib.parse.unquote` and
:func:`urllib.parse.unquote_to_bytes` on large values.