mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Fix Issue9301 - urllib.quote(None) to raise TypeError
This commit is contained in:
parent
e9a6a7dd4c
commit
c7743aaac3
2 changed files with 3 additions and 0 deletions
|
|
@ -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):
|
||||||
"""
|
"""
|
||||||
# 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):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue