diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-07-19 17:35:50 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-07-19 17:35:50 (GMT) |
commit | c7743aaac3b318c3e4c8583d8b1e5f3be267d119 (patch) | |
tree | 291c2ccf9af29da370a5a138bccc88802323ffca | |
parent | e9a6a7dd4c19d2630ff1d24ce6d9f30879138e81 (diff) | |
download | cpython-c7743aaac3b318c3e4c8583d8b1e5f3be267d119.zip cpython-c7743aaac3b318c3e4c8583d8b1e5f3be267d119.tar.gz cpython-c7743aaac3b318c3e4c8583d8b1e5f3be267d119.tar.bz2 |
Fix Issue9301 - urllib.quote(None) to raise TypeError
-rw-r--r-- | Lib/test/test_urllib.py | 1 | ||||
-rw-r--r-- | Lib/urllib.py | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 77fa8f6..16febae 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -413,6 +413,7 @@ class QuotingTests(unittest.TestCase): "using quote(): %s != %s" % (expected, result)) self.assertEqual(expected, result, "using quote_plus(): %s != %s" % (expected, result)) + self.assertRaises(TypeError, urllib.quote, None) def test_quoting_space(self): # Make sure quote() and quote_plus() handle spaces as specified in diff --git a/Lib/urllib.py b/Lib/urllib.py index e32a771..3460a56 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -1223,6 +1223,8 @@ def quote(s, safe='/', encoding=None, errors=None): """ # fastpath if not s: + if s is None: + raise TypeError('None object cannot be quoted') return s if encoding is not None or isinstance(s, unicode): |