diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-11-12 19:10:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-12 19:10:29 (GMT) |
commit | 7577307ebdaeef6702b639e22a896080e81aae4e (patch) | |
tree | 0fabee28382b27e06d4ef8658d58b447f07d421a /Lib/test | |
parent | 03924b5deeb766fabd53ced28ba707e4dd08fb60 (diff) | |
download | cpython-7577307ebdaeef6702b639e22a896080e81aae4e.zip cpython-7577307ebdaeef6702b639e22a896080e81aae4e.tar.gz cpython-7577307ebdaeef6702b639e22a896080e81aae4e.tar.bz2 |
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.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_urlparse.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index 297fb48..4516bde 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -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')) |