@@ -1562,7 +1562,7 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc,
15621562 PyObject * ident = NULL ;
15631563 PyObject * it = NULL ;
15641564 PyObject * items ;
1565- PyObject * coerced_items ;
1565+ PyObject * coerced_items ;
15661566 PyObject * item = NULL ;
15671567 Py_ssize_t idx ;
15681568
@@ -1609,63 +1609,63 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc,
16091609 if (items == NULL )
16101610 goto bail ;
16111611
1612- coerced_items = PyList_New (0 );
1613- it = PyObject_GetIter (items );
1614- Py_DECREF (items );
1615- if (it == NULL )
1616- goto bail ;
1617-
1618- while ((item = PyIter_Next (it )) != NULL ) {
1619- PyObject * key , * value , * coerced_item ;
1620- if (!PyTuple_Check (item ) || PyTuple_GET_SIZE (item ) != 2 ) {
1621- PyErr_SetString (PyExc_ValueError , "items must return 2-tuples" );
1622- goto bail ;
1623- }
1624- key = PyTuple_GET_ITEM (item , 0 );
1625- if (PyUnicode_Check (key )) {
1626- Py_INCREF (key );
1627- kstr = key ;
1628- }
1629- else if (PyFloat_Check (key )) {
1630- kstr = encoder_encode_float (s , key );
1631- if (kstr == NULL )
1632- goto bail ;
1633- }
1634- else if (key == Py_True || key == Py_False || key == Py_None ) {
1635- /* This must come before the PyLong_Check because
1636- True and False are also 1 and 0.*/
1637- kstr = _encoded_const (key );
1638- if (kstr == NULL )
1639- goto bail ;
1640- }
1641- else if (PyLong_Check (key )) {
1642- kstr = PyLong_Type .tp_str (key );
1643- if (kstr == NULL ) {
1644- goto bail ;
1645- }
1646- }
1647- else if (s -> skipkeys ) {
1648- Py_DECREF (item );
1649- continue ;
1650- }
1651- else {
1652- PyErr_Format (PyExc_TypeError ,
1653- "keys must be str, int, float, bool or None, "
1654- "not %.100s" , key -> ob_type -> tp_name );
1655- goto bail ;
1656- }
1657-
1658- value = PyTuple_GET_ITEM (item , 1 );
1659- coerced_item = PyTuple_Pack (2 , kstr , value );
1660- if (coerced_item == NULL ) {
1661- goto bail ;
1662- }
1663- /* Append instead of set because skipkeys=True may
1664- "shrink" the number of items */
1665- if (-1 == PyList_Append (coerced_items , coerced_item ))
1666- goto bail ;
1667- }
1668-
1612+ coerced_items = PyList_New (0 );
1613+ it = PyObject_GetIter (items );
1614+ Py_DECREF (items );
1615+ if (it == NULL )
1616+ goto bail ;
1617+
1618+ while ((item = PyIter_Next (it )) != NULL ) {
1619+ PyObject * key , * value , * coerced_item ;
1620+ if (!PyTuple_Check (item ) || PyTuple_GET_SIZE (item ) != 2 ) {
1621+ PyErr_SetString (PyExc_ValueError , "items must return 2-tuples" );
1622+ goto bail ;
1623+ }
1624+ key = PyTuple_GET_ITEM (item , 0 );
1625+ if (PyUnicode_Check (key )) {
1626+ Py_INCREF (key );
1627+ kstr = key ;
1628+ }
1629+ else if (PyFloat_Check (key )) {
1630+ kstr = encoder_encode_float (s , key );
1631+ if (kstr == NULL )
1632+ goto bail ;
1633+ }
1634+ else if (key == Py_True || key == Py_False || key == Py_None ) {
1635+ /* This must come before the PyLong_Check because
1636+ True and False are also 1 and 0.*/
1637+ kstr = _encoded_const (key );
1638+ if (kstr == NULL )
1639+ goto bail ;
1640+ }
1641+ else if (PyLong_Check (key )) {
1642+ kstr = PyLong_Type .tp_str (key );
1643+ if (kstr == NULL ) {
1644+ goto bail ;
1645+ }
1646+ }
1647+ else if (s -> skipkeys ) {
1648+ Py_DECREF (item );
1649+ continue ;
1650+ }
1651+ else {
1652+ PyErr_Format (PyExc_TypeError ,
1653+ "keys must be str, int, float, bool or None, "
1654+ "not %.100s" , key -> ob_type -> tp_name );
1655+ goto bail ;
1656+ }
1657+
1658+ value = PyTuple_GET_ITEM (item , 1 );
1659+ coerced_item = PyTuple_Pack (2 , kstr , value );
1660+ if (coerced_item == NULL ) {
1661+ goto bail ;
1662+ }
1663+ /* Append instead of set because skipkeys=True may
1664+ "shrink" the number of items */
1665+ if (-1 == PyList_Append (coerced_items , coerced_item ))
1666+ goto bail ;
1667+ }
1668+
16691669 if (s -> sort_keys && PyList_Sort (coerced_items ) < 0 ) {
16701670 Py_DECREF (coerced_items );
16711671 goto bail ;
@@ -1730,7 +1730,7 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc,
17301730 Py_XDECREF (item );
17311731 Py_XDECREF (kstr );
17321732 Py_XDECREF (ident );
1733- Py_XDECREF (coerced_items );
1733+ Py_XDECREF (coerced_items );
17341734 return -1 ;
17351735}
17361736
0 commit comments