summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-09-28 21:51:57 (GMT)
committerGitHub <noreply@github.com>2021-09-28 21:51:57 (GMT)
commitc6b5ceae3475d7782ed88f4e54bdb2232a8eb088 (patch)
treee30f8a40b5330afa8116546ab0076c348705af33
parent68223cd12f81adcb14f28f619d08a7f6a634fcc5 (diff)
downloadcpython-c6b5ceae3475d7782ed88f4e54bdb2232a8eb088.zip
cpython-c6b5ceae3475d7782ed88f4e54bdb2232a8eb088.tar.gz
cpython-c6b5ceae3475d7782ed88f4e54bdb2232a8eb088.tar.bz2
bpo-45269: test wrong `markers` type to `c_make_encoder` (GH-28540) (GH-28610)
(cherry picked from commit e046aabbe386fdf32bae6ffb7fae5ce479fd10c6) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
-rw-r--r--Lib/test/test_json/test_speedups.py9
-rw-r--r--Misc/NEWS.d/next/Tests/2021-09-24-10-41-49.bpo-45269.8jKEr8.rst1
2 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_json/test_speedups.py b/Lib/test/test_json/test_speedups.py
index fbfee1a..682014c 100644
--- a/Lib/test/test_json/test_speedups.py
+++ b/Lib/test/test_json/test_speedups.py
@@ -59,6 +59,15 @@ class TestEncode(CTest):
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 0000000..72dd947
--- /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``.