@@ -1301,10 +1301,18 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi
13011301 return _steal_list_append (rval , encoded );
13021302 }
13031303 else if (PyList_Check (obj ) || PyTuple_Check (obj )) {
1304- return encoder_listencode_list (s , rval , obj , indent_level );
1304+ if (Py_EnterRecursiveCall (" while encoding a JSON object" ))
1305+ return -1 ;
1306+ rv = encoder_listencode_list (s , rval , obj , indent_level );
1307+ Py_LeaveRecursiveCall ();
1308+ return rv ;
13051309 }
13061310 else if (PyDict_Check (obj )) {
1307- return encoder_listencode_dict (s , rval , obj , indent_level );
1311+ if (Py_EnterRecursiveCall (" while encoding a JSON object" ))
1312+ return -1 ;
1313+ rv = encoder_listencode_dict (s , rval , obj , indent_level );
1314+ Py_LeaveRecursiveCall ();
1315+ return rv ;
13081316 }
13091317 else {
13101318 PyObject * ident = NULL ;
@@ -1330,7 +1338,12 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi
13301338 Py_XDECREF (ident );
13311339 return -1 ;
13321340 }
1341+
1342+ if (Py_EnterRecursiveCall (" while encoding a JSON object" ))
1343+ return -1 ;
13331344 rv = encoder_listencode_obj (s , rval , newobj , indent_level );
1345+ Py_LeaveRecursiveCall ();
1346+
13341347 Py_DECREF (newobj );
13351348 if (rv ) {
13361349 Py_XDECREF (ident );
0 commit comments