diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 77fa8f6e876..16febaec449 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 e32a7719331..3460a566574 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):