]> granicus.if.org Git - python/commitdiff
Fix Issue9301 - urllib.quote(None) to raise TypeError
authorSenthil Kumaran <orsenthil@gmail.com>
Mon, 19 Jul 2010 17:35:50 +0000 (17:35 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Mon, 19 Jul 2010 17:35:50 +0000 (17:35 +0000)
Lib/test/test_urllib.py
Lib/urllib.py

index 77fa8f6e876f49bb8fe51f0879b4159d4438bac9..16febaec4490c88913436d1f242ac0aad9fec0f3 100644 (file)
@@ -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
index e32a7719331e9e3842ba65d1298b98feb17a7c88..3460a5665749536a4f6071a7ad51da90dae953eb 100644 (file)
@@ -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):