summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt8
-rw-r--r--simplejson/_speedups.c6
2 files changed, 14 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index a397ece..67514d4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,11 @@
+Version 3.17.5 released 2021-08-XX
+
+* Fix the C extension module to harden is_namedtuple against looks-a-likes such
+ as Mocks. Also prevent dict encoding from causing an unraised SystemError when
+ encountering a non-Dict. Noticed by running user tests against a CPython
+ interpreter with C asserts enabled (COPTS += -UNDEBUG).
+ https://github.com/simplejson/simplejson/pull/284
+
Version 3.17.4 released 2021-08-19
* Upgrade cibuildwheel
diff --git a/simplejson/_speedups.c b/simplejson/_speedups.c
index e710128..7c3b6b0 100644
--- a/simplejson/_speedups.c
+++ b/simplejson/_speedups.c
@@ -386,6 +386,9 @@ static int
_is_namedtuple(PyObject *obj)
{
int rval = 0;
+ if (!PyTuple_Check(obj)) {
+ return 0;
+ }
PyObject *_asdict = PyObject_GetAttrString(obj, "_asdict");
if (_asdict == NULL) {
PyErr_Clear();
@@ -2953,6 +2956,9 @@ encoder_listencode_dict(PyEncoderObject *s, JSON_Accu *rval, PyObject *dct, Py_s
PyObject *encoded = NULL;
Py_ssize_t idx;
+ if (!PyDict_Check(dct)) {
+ return -1;
+ }
if (open_dict == NULL || close_dict == NULL || empty_dict == NULL) {
open_dict = JSON_InternFromString("{");
close_dict = JSON_InternFromString("}");