diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-10 22:10:27 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-10 22:10:27 (GMT) |
commit | f188bc5d4618103bd86a49a6b473e4a86e6b22b7 (patch) | |
tree | c37719be16c95847c93031692424c3a69ff255ae /Modules | |
parent | ccc87b53dba9ca3558ce8d333d9eb9274c16b0f4 (diff) | |
parent | 136726537ffd92b0f3e8dabb23023ed514852e2e (diff) | |
download | cpython-f188bc5d4618103bd86a49a6b473e4a86e6b22b7.zip cpython-f188bc5d4618103bd86a49a6b473e4a86e6b22b7.tar.gz cpython-f188bc5d4618103bd86a49a6b473e4a86e6b22b7.tar.bz2 |
#12051: merge with 3.1.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_json.c | 17 |
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); |