Commit c7743aaa authored by Senthil Kumaran's avatar Senthil Kumaran

Fix Issue9301 - urllib.quote(None) to raise TypeError

parent e9a6a7dd
...@@ -413,6 +413,7 @@ class QuotingTests(unittest.TestCase): ...@@ -413,6 +413,7 @@ class QuotingTests(unittest.TestCase):
"using quote(): %s != %s" % (expected, result)) "using quote(): %s != %s" % (expected, result))
self.assertEqual(expected, result, self.assertEqual(expected, result,
"using quote_plus(): %s != %s" % (expected, result)) "using quote_plus(): %s != %s" % (expected, result))
self.assertRaises(TypeError, urllib.quote, None)
def test_quoting_space(self): def test_quoting_space(self):
# Make sure quote() and quote_plus() handle spaces as specified in # Make sure quote() and quote_plus() handle spaces as specified in
......
...@@ -1223,6 +1223,8 @@ def quote(s, safe='/', encoding=None, errors=None): ...@@ -1223,6 +1223,8 @@ def quote(s, safe='/', encoding=None, errors=None):
""" """
# fastpath # fastpath
if not s: if not s:
if s is None:
raise TypeError('None object cannot be quoted')
return s return s
if encoding is not None or isinstance(s, unicode): if encoding is not None or isinstance(s, unicode):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment