@@ -1639,12 +1639,11 @@ encoder_encode_key_value(PyEncoderObject *s, PyUnicodeWriter *writer, bool *firs
16391639
16401640static  inline  int 
16411641_encoder_iterate_mapping_lock_held (PyEncoderObject  * s , PyUnicodeWriter  * writer ,
1642-                             PyObject  * dct , PyObject  * items ,
1642+                             bool   * first ,  PyObject  * dct , PyObject  * items ,
16431643                            Py_ssize_t  indent_level , PyObject  * indent_cache ,
16441644                            PyObject  * separator )
16451645{
16461646    PyObject  * key , * value ;
1647-     bool  first  =  true;
16481647    for  (Py_ssize_t   i  =  0 ; i  <  PyList_GET_SIZE (items ); i ++ ) {
16491648        PyObject  * item  =  PyList_GET_ITEM (items , i );
16501649
@@ -1655,7 +1654,7 @@ _encoder_iterate_mapping_lock_held(PyEncoderObject *s, PyUnicodeWriter *writer,
16551654
16561655        key  =  PyTuple_GET_ITEM (item , 0 );
16571656        value  =  PyTuple_GET_ITEM (item , 1 );
1658-         if  (encoder_encode_key_value (s , writer , & first , dct , key , value ,
1657+         if  (encoder_encode_key_value (s , writer , first , dct , key , value ,
16591658                                     indent_level , indent_cache ,
16601659                                     separator ) <  0 ) {
16611660            return  -1 ;
@@ -1667,14 +1666,13 @@ _encoder_iterate_mapping_lock_held(PyEncoderObject *s, PyUnicodeWriter *writer,
16671666
16681667static  inline  int 
16691668_encoder_iterate_dict_lock_held (PyEncoderObject  * s , PyUnicodeWriter  * writer ,
1670-                          PyObject  * dct , Py_ssize_t  indent_level ,
1669+                          bool   * first ,  PyObject  * dct , Py_ssize_t  indent_level ,
16711670                         PyObject  * indent_cache , PyObject  * separator )
16721671{
16731672    PyObject  * key , * value ;
16741673    Py_ssize_t  pos  =  0 ;
1675-     bool  first  =  true;
16761674    while  (PyDict_Next (dct , & pos , & key , & value )) {
1677-         if  (encoder_encode_key_value (s , writer , & first , dct , key , value ,
1675+         if  (encoder_encode_key_value (s , writer , first , dct , key , value ,
16781676                                    indent_level , indent_cache ,
16791677                                    separator ) <  0 ) {
16801678            return  -1 ;
@@ -1685,12 +1683,13 @@ _encoder_iterate_dict_lock_held(PyEncoderObject *s, PyUnicodeWriter *writer,
16851683
16861684static  int 
16871685encoder_listencode_dict (PyEncoderObject  * s , PyUnicodeWriter  * writer ,
1688-                          PyObject  * dct ,
1686+                        PyObject  * dct ,
16891687                       Py_ssize_t  indent_level , PyObject  * indent_cache )
16901688{
16911689    /* Encode Python dict dct a JSON term */ 
16921690    PyObject  * ident  =  NULL ;
16931691    PyObject  * items  =  NULL ;
1692+     bool  first  =  true;
16941693
16951694    if  (PyDict_GET_SIZE (dct ) ==  0 ) {
16961695        /* Fast path */ 
@@ -1733,7 +1732,7 @@ encoder_listencode_dict(PyEncoderObject *s, PyUnicodeWriter *writer,
17331732
17341733        int  result ;
17351734        Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST (items );
1736-         result  =  _encoder_iterate_mapping_lock_held (s , writer , dct ,
1735+         result  =  _encoder_iterate_mapping_lock_held (s , writer , & first ,  dct ,
17371736                    items , indent_level , indent_cache , separator );
17381737        Py_END_CRITICAL_SECTION_SEQUENCE_FAST ();
17391738        Py_CLEAR (items );
@@ -1745,7 +1744,7 @@ encoder_listencode_dict(PyEncoderObject *s, PyUnicodeWriter *writer,
17451744    } else  {
17461745        int  result ;
17471746        Py_BEGIN_CRITICAL_SECTION (dct );
1748-         result  =  _encoder_iterate_dict_lock_held (s , writer , dct ,
1747+         result  =  _encoder_iterate_dict_lock_held (s , writer , & first ,  dct ,
17491748                            indent_level , indent_cache , separator );
17501749        Py_END_CRITICAL_SECTION ();
17511750        if  (result  <  0 ) {
0 commit comments