summaryrefslogtreecommitdiffstats
path: root/Modules/_json.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_json.c')
-rw-r--r--Modules/_json.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index dd71003..0924873 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -1338,10 +1338,18 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi
return _steal_list_append(rval, encoded);
}
else if (PyList_Check(obj) || PyTuple_Check(obj)) {
- return encoder_listencode_list(s, rval, obj, indent_level);
+ if (Py_EnterRecursiveCall(" while encoding a JSON object"))
+ return -1;
+ rv = encoder_listencode_list(s, rval, obj, indent_level);
+ Py_LeaveRecursiveCall();
+ return rv;
}
else if (PyDict_Check(obj)) {
- return encoder_listencode_dict(s, rval, obj, indent_level);
+ if (Py_EnterRecursiveCall(" while encoding a JSON object"))
+ return -1;
+ rv = encoder_listencode_dict(s, rval, obj, indent_level);
+ Py_LeaveRecursiveCall();
+ return rv;
}
else {
PyObject *ident = NULL;
@@ -1367,7 +1375,12 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi
Py_XDECREF(ident);
return -1;
}
+
+ if (Py_EnterRecursiveCall(" while encoding a JSON object"))
+ return -1;
rv = encoder_listencode_obj(s, rval, newobj, indent_level);
+ Py_LeaveRecursiveCall();
+
Py_DECREF(newobj);
if (rv) {
Py_XDECREF(ident);