Silence the BytesWarning, due to patch r83294 for #9301

This commit is contained in:
Florent Xicluna 2010-08-14 18:30:35 +00:00
parent ac521078d7
commit 82a3f8afcb
1 changed files with 3 additions and 1 deletions

View File

@ -314,7 +314,9 @@ 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 string in (b'', ''):
if not string:
# Is it a string-like object?
string.split
return b''
if isinstance(string, str):
string = string.encode('utf-8')