mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Fix issue9301 - handle unquote({}) kind of case.
This commit is contained in:
parent
0a9c3e91dc
commit
d496c4c936
2 changed files with 5 additions and 7 deletions
|
@ -313,9 +313,7 @@ def unquote_to_bytes(string):
|
|||
"""unquote_to_bytes('abc%20def') -> b'abc def'."""
|
||||
# Note: strings are encoded as UTF-8. This is only an issue if it contains
|
||||
# unescaped non-ASCII characters, which URIs should not.
|
||||
if not string:
|
||||
if string is None:
|
||||
raise TypeError('None object is invalid for unquote_to_bytes()')
|
||||
if string in (b'', ''):
|
||||
return b''
|
||||
if isinstance(string, str):
|
||||
string = string.encode('utf-8')
|
||||
|
@ -340,9 +338,7 @@ def unquote(string, encoding='utf-8', errors='replace'):
|
|||
|
||||
unquote('abc%20def') -> 'abc def'.
|
||||
"""
|
||||
if not string:
|
||||
if string is None:
|
||||
raise TypeError('None object is invalid for unquote() function.')
|
||||
if string in (b'', ''):
|
||||
return string
|
||||
res = string.split('%')
|
||||
if len(res) == 1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue