self.assertEqual(expect, result,
"using unquote(): %r != %r" % (expect, result))
+ def test_unquoting_with_bytes_input(self):
+ # Bytes not supported yet
+ with self.assertRaisesRegex(TypeError, 'Expected str, got bytes'):
+ given = b'bl\xc3\xa5b\xc3\xa6rsyltet\xc3\xb8y'
+ urllib.parse.unquote(given)
+
class urlencode_Tests(unittest.TestCase):
"""Tests for urlencode()"""
unquote('abc%20def') -> 'abc def'.
"""
+ if isinstance(string, bytes):
+ raise TypeError('Expected str, got bytes')
if '%' not in string:
string.split
return string
--- /dev/null
+Clearer exception message when passing an argument of type bytes to
+:func:`urllib.parse.unquote`. This is only for 3.8; in 3.9 and later this
+function accepts bytes inputs as well. PR by Irit Katriel.