[Python-checkins] bpo-45269: test wrong `markers` type to `c_make_encoder` (GH-28540) (GH-28609)

ambv webhook-mailer at python.org
Tue Sep 28 17:57:00 EDT 2021


https://github.com/python/cpython/commit/1cb17be3e6a4d94629606a613acd07f78d50348b
commit: 1cb17be3e6a4d94629606a613acd07f78d50348b
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2021-09-28T23:56:52+02:00
summary:

bpo-45269: test wrong `markers` type to `c_make_encoder` (GH-28540) (GH-28609)

(cherry picked from commit e046aabbe386fdf32bae6ffb7fae5ce479fd10c6)

Co-authored-by: Nikita Sobolev <mail at sobolevn.me>

files:
A Misc/NEWS.d/next/Tests/2021-09-24-10-41-49.bpo-45269.8jKEr8.rst
M Lib/test/test_json/test_speedups.py

diff --git a/Lib/test/test_json/test_speedups.py b/Lib/test/test_json/test_speedups.py
index fbfee1a582095..682014cfd5b34 100644
--- a/Lib/test/test_json/test_speedups.py
+++ b/Lib/test/test_json/test_speedups.py
@@ -59,6 +59,15 @@ def bad_encoder2(*args):
         with self.assertRaises(ZeroDivisionError):
             enc('spam', 4)
 
+    def test_bad_markers_argument_to_encoder(self):
+        # https://bugs.python.org/issue45269
+        with self.assertRaisesRegex(
+            TypeError,
+            r'make_encoder\(\) argument 1 must be dict or None, not int',
+        ):
+            self.json.encoder.c_make_encoder(1, None, None, None, ': ', ', ',
+                                             False, False, False)
+
     def test_bad_bool_args(self):
         def test(name):
             self.json.encoder.JSONEncoder(**{name: BadBool()}).encode({'a': 1})
diff --git a/Misc/NEWS.d/next/Tests/2021-09-24-10-41-49.bpo-45269.8jKEr8.rst b/Misc/NEWS.d/next/Tests/2021-09-24-10-41-49.bpo-45269.8jKEr8.rst
new file mode 100644
index 0000000000000..72dd9471134ff
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2021-09-24-10-41-49.bpo-45269.8jKEr8.rst
@@ -0,0 +1 @@
+Cover case when invalid ``markers`` type is supplied to ``c_make_encoder``.



More information about the Python-checkins mailing list