@@ -1354,10 +1354,18 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi
13541354 return _steal_list_append (rval , encoded );
13551355 }
13561356 else if (PyList_Check (obj ) || PyTuple_Check (obj )) {
1357- return encoder_listencode_list (s , rval , obj , indent_level );
1357+ if (Py_EnterRecursiveCall (" while encoding a JSON object" ))
1358+ return -1 ;
1359+ rv = encoder_listencode_list (s , rval , obj , indent_level );
1360+ Py_LeaveRecursiveCall ();
1361+ return rv ;
13581362 }
13591363 else if (PyDict_Check (obj )) {
1360- return encoder_listencode_dict (s , rval , obj , indent_level );
1364+ if (Py_EnterRecursiveCall (" while encoding a JSON object" ))
1365+ return -1 ;
1366+ rv = encoder_listencode_dict (s , rval , obj , indent_level );
1367+ Py_LeaveRecursiveCall ();
1368+ return rv ;
13611369 }
13621370 else {
13631371 PyObject * ident = NULL ;
@@ -1383,7 +1391,12 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi
13831391 Py_XDECREF (ident );
13841392 return -1 ;
13851393 }
1394+
1395+ if (Py_EnterRecursiveCall (" while encoding a JSON object" ))
1396+ return -1 ;
13861397 rv = encoder_listencode_obj (s , rval , newobj , indent_level );
1398+ Py_LeaveRecursiveCall ();
1399+
13871400 Py_DECREF (newobj );
13881401 if (rv ) {
13891402 Py_XDECREF (ident );
0 commit comments