mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Fix Issue9301 - urllib.parse.unquote and unquote_to_byte to raise TypeError for None.
This commit is contained in:
parent
99212f61db
commit
79e17f6f66
2 changed files with 7 additions and 0 deletions
|
@ -314,6 +314,8 @@ def unquote_to_bytes(string):
|
|||
# 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()')
|
||||
return b''
|
||||
if isinstance(string, str):
|
||||
string = string.encode('utf-8')
|
||||
|
@ -339,6 +341,8 @@ 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.')
|
||||
return string
|
||||
res = string.split('%')
|
||||
if len(res) == 1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue