mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-116897: Deprecate generic false values in urllib.parse.parse_qsl() (GH-116903)
Accepting objects with false values (like 0 and []) except empty strings and byte-like objects and None in urllib.parse functions parse_qsl() and parse_qs() is now deprecated.
This commit is contained in:
parent
03924b5dee
commit
7577307ebd
5 changed files with 45 additions and 9 deletions
|
@ -1314,9 +1314,17 @@ class UrlParseTestCase(unittest.TestCase):
|
|||
|
||||
def test_parse_qsl_false_value(self):
|
||||
kwargs = dict(keep_blank_values=True, strict_parsing=True)
|
||||
for x in '', b'', None, 0, 0.0, [], {}, memoryview(b''):
|
||||
for x in '', b'', None, memoryview(b''):
|
||||
self.assertEqual(urllib.parse.parse_qsl(x, **kwargs), [])
|
||||
self.assertRaises(ValueError, urllib.parse.parse_qsl, x, separator=1)
|
||||
for x in 0, 0.0, [], {}:
|
||||
with self.assertWarns(DeprecationWarning) as cm:
|
||||
self.assertEqual(urllib.parse.parse_qsl(x, **kwargs), [])
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
with self.assertWarns(DeprecationWarning) as cm:
|
||||
self.assertEqual(urllib.parse.parse_qs(x, **kwargs), {})
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
self.assertRaises(ValueError, urllib.parse.parse_qsl, x, separator=1)
|
||||
|
||||
def test_parse_qsl_errors(self):
|
||||
self.assertRaises(TypeError, urllib.parse.parse_qsl, list(b'a=b'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue