@@ -1338,10 +1338,18 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi
13381338 return _steal_list_append (rval , encoded );
13391339 }
13401340 else if (PyList_Check (obj ) || PyTuple_Check (obj )) {
1341- return encoder_listencode_list (s , rval , obj , indent_level );
1341+ if (Py_EnterRecursiveCall (" while encoding a JSON object" ))
1342+ return -1 ;
1343+ rv = encoder_listencode_list (s , rval , obj , indent_level );
1344+ Py_LeaveRecursiveCall ();
1345+ return rv ;
13421346 }
13431347 else if (PyDict_Check (obj )) {
1344- return encoder_listencode_dict (s , rval , obj , indent_level );
1348+ if (Py_EnterRecursiveCall (" while encoding a JSON object" ))
1349+ return -1 ;
1350+ rv = encoder_listencode_dict (s , rval , obj , indent_level );
1351+ Py_LeaveRecursiveCall ();
1352+ return rv ;
13451353 }
13461354 else {
13471355 PyObject * ident = NULL ;
@@ -1367,7 +1375,12 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi
13671375 Py_XDECREF (ident );
13681376 return -1 ;
13691377 }
1378+
1379+ if (Py_EnterRecursiveCall (" while encoding a JSON object" ))
1380+ return -1 ;
13701381 rv = encoder_listencode_obj (s , rval , newobj , indent_level );
1382+ Py_LeaveRecursiveCall ();
1383+
13711384 Py_DECREF (newobj );
13721385 if (rv ) {
13731386 Py_XDECREF (ident );
0 commit comments