From c049fca0da0b81b04060d52443af493afa560ee8 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Sat, 31 Jul 2010 08:56:55 +0000 Subject: [PATCH] Fix an oversight in r83294. unquote() should reject bytes. Issue #9301. --- Lib/test/test_urllib.py | 1 + Lib/urllib/parse.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index c68fe54b939..cea153e907a 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -557,6 +557,7 @@ class UnquotingTests(unittest.TestCase): "%s" % result) self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, None) self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, ()) + self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, b'') def test_unquoting_badpercent(self): # Test unquoting on bad percent-escapes diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index a9fa26ad8f6..133b9d99b60 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -338,7 +338,7 @@ def unquote(string, encoding='utf-8', errors='replace'): unquote('abc%20def') -> 'abc def'. """ - if string in (b'', ''): + if string == '': return string res = string.split('%') if len(res) == 1: