mirror of https://github.com/python/cpython
Fix an oversight in r83294. unquote() should reject bytes. Issue #9301.
This commit is contained in:
parent
62069d3ce7
commit
c049fca0da
|
@ -557,6 +557,7 @@ class UnquotingTests(unittest.TestCase):
|
||||||
"%s" % result)
|
"%s" % result)
|
||||||
self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, None)
|
self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, None)
|
||||||
self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, ())
|
self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, ())
|
||||||
|
self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, b'')
|
||||||
|
|
||||||
def test_unquoting_badpercent(self):
|
def test_unquoting_badpercent(self):
|
||||||
# Test unquoting on bad percent-escapes
|
# Test unquoting on bad percent-escapes
|
||||||
|
|
|
@ -338,7 +338,7 @@ def unquote(string, encoding='utf-8', errors='replace'):
|
||||||
|
|
||||||
unquote('abc%20def') -> 'abc def'.
|
unquote('abc%20def') -> 'abc def'.
|
||||||
"""
|
"""
|
||||||
if string in (b'', ''):
|
if string == '':
|
||||||
return string
|
return string
|
||||||
res = string.split('%')
|
res = string.split('%')
|
||||||
if len(res) == 1:
|
if len(res) == 1:
|
||||||
|
|
Loading…
Reference in New Issue