@@ -1242,7 +1242,6 @@ encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
12421242 if (s == NULL )
12431243 return NULL ;
12441244
1245- s -> markers = Py_NewRef (markers );
12461245 s -> defaultfn = Py_NewRef (defaultfn );
12471246 s -> encoder = Py_NewRef (encoder );
12481247 s -> indent = Py_NewRef (indent );
@@ -1521,33 +1520,13 @@ encoder_listencode_obj(PyEncoderObject *s, PyUnicodeWriter *writer,
15211520 return rv ;
15221521 }
15231522 else {
1524- PyObject * ident = NULL ;
1525- if (s -> markers != Py_None ) {
1526- int has_key ;
1527- ident = PyLong_FromVoidPtr (obj );
1528- if (ident == NULL )
1529- return -1 ;
1530- has_key = PyDict_Contains (s -> markers , ident );
1531- if (has_key ) {
1532- if (has_key != -1 )
1533- PyErr_SetString (PyExc_ValueError , "Circular reference detected" );
1534- Py_DECREF (ident );
1535- return -1 ;
1536- }
1537- if (PyDict_SetItem (s -> markers , ident , obj )) {
1538- Py_DECREF (ident );
1539- return -1 ;
1540- }
1541- }
15421523 newobj = PyObject_CallOneArg (s -> defaultfn , obj );
15431524 if (newobj == NULL ) {
1544- Py_XDECREF (ident );
15451525 return -1 ;
15461526 }
15471527
15481528 if (_Py_EnterRecursiveCall (" while encoding a JSON object" )) {
15491529 Py_DECREF (newobj );
1550- Py_XDECREF (ident );
15511530 return -1 ;
15521531 }
15531532 rv = encoder_listencode_obj (s , writer , newobj , indent_level , indent_cache );
@@ -1556,16 +1535,8 @@ encoder_listencode_obj(PyEncoderObject *s, PyUnicodeWriter *writer,
15561535 Py_DECREF (newobj );
15571536 if (rv ) {
15581537 _PyErr_FormatNote ("when serializing %T object" , obj );
1559- Py_XDECREF (ident );
15601538 return -1 ;
15611539 }
1562- if (ident != NULL ) {
1563- if (PyDict_DelItem (s -> markers , ident )) {
1564- Py_XDECREF (ident );
1565- return -1 ;
1566- }
1567- Py_XDECREF (ident );
1568- }
15691540 return rv ;
15701541 }
15711542}
@@ -1642,7 +1613,6 @@ encoder_listencode_dict(PyEncoderObject *s, PyUnicodeWriter *writer,
16421613 Py_ssize_t indent_level , PyObject * indent_cache )
16431614{
16441615 /* Encode Python dict dct a JSON term */
1645- PyObject * ident = NULL ;
16461616 PyObject * items = NULL ;
16471617 PyObject * key , * value ;
16481618 bool first = true;
@@ -1652,22 +1622,6 @@ encoder_listencode_dict(PyEncoderObject *s, PyUnicodeWriter *writer,
16521622 return PyUnicodeWriter_WriteASCII (writer , "{}" , 2 );
16531623 }
16541624
1655- if (s -> markers != Py_None ) {
1656- int has_key ;
1657- ident = PyLong_FromVoidPtr (dct );
1658- if (ident == NULL )
1659- goto bail ;
1660- has_key = PyDict_Contains (s -> markers , ident );
1661- if (has_key ) {
1662- if (has_key != -1 )
1663- PyErr_SetString (PyExc_ValueError , "Circular reference detected" );
1664- goto bail ;
1665- }
1666- if (PyDict_SetItem (s -> markers , ident , dct )) {
1667- goto bail ;
1668- }
1669- }
1670-
16711625 if (PyUnicodeWriter_WriteChar (writer , '{' )) {
16721626 goto bail ;
16731627 }
@@ -1715,11 +1669,6 @@ encoder_listencode_dict(PyEncoderObject *s, PyUnicodeWriter *writer,
17151669 }
17161670 }
17171671
1718- if (ident != NULL ) {
1719- if (PyDict_DelItem (s -> markers , ident ))
1720- goto bail ;
1721- Py_CLEAR (ident );
1722- }
17231672 if (s -> indent != Py_None ) {
17241673 indent_level -- ;
17251674 if (write_newline_indent (writer , indent_level , indent_cache ) < 0 ) {
@@ -1734,7 +1683,6 @@ encoder_listencode_dict(PyEncoderObject *s, PyUnicodeWriter *writer,
17341683
17351684bail :
17361685 Py_XDECREF (items );
1737- Py_XDECREF (ident );
17381686 return -1 ;
17391687}
17401688
@@ -1743,11 +1691,9 @@ encoder_listencode_list(PyEncoderObject *s, PyUnicodeWriter *writer,
17431691 PyObject * seq ,
17441692 Py_ssize_t indent_level , PyObject * indent_cache )
17451693{
1746- PyObject * ident = NULL ;
17471694 PyObject * s_fast = NULL ;
17481695 Py_ssize_t i ;
17491696
1750- ident = NULL ;
17511697 s_fast = PySequence_Fast (seq , "_iterencode_list needs a sequence" );
17521698 if (s_fast == NULL )
17531699 return -1 ;
@@ -1756,22 +1702,6 @@ encoder_listencode_list(PyEncoderObject *s, PyUnicodeWriter *writer,
17561702 return PyUnicodeWriter_WriteASCII (writer , "[]" , 2 );
17571703 }
17581704
1759- if (s -> markers != Py_None ) {
1760- int has_key ;
1761- ident = PyLong_FromVoidPtr (seq );
1762- if (ident == NULL )
1763- goto bail ;
1764- has_key = PyDict_Contains (s -> markers , ident );
1765- if (has_key ) {
1766- if (has_key != -1 )
1767- PyErr_SetString (PyExc_ValueError , "Circular reference detected" );
1768- goto bail ;
1769- }
1770- if (PyDict_SetItem (s -> markers , ident , seq )) {
1771- goto bail ;
1772- }
1773- }
1774-
17751705 if (PyUnicodeWriter_WriteChar (writer , '[' )) {
17761706 goto bail ;
17771707 }
@@ -1797,11 +1727,6 @@ encoder_listencode_list(PyEncoderObject *s, PyUnicodeWriter *writer,
17971727 goto bail ;
17981728 }
17991729 }
1800- if (ident != NULL ) {
1801- if (PyDict_DelItem (s -> markers , ident ))
1802- goto bail ;
1803- Py_CLEAR (ident );
1804- }
18051730
18061731 if (s -> indent != Py_None ) {
18071732 indent_level -- ;
@@ -1817,7 +1742,6 @@ encoder_listencode_list(PyEncoderObject *s, PyUnicodeWriter *writer,
18171742 return 0 ;
18181743
18191744bail :
1820- Py_XDECREF (ident );
18211745 Py_DECREF (s_fast );
18221746 return -1 ;
18231747}
@@ -1838,7 +1762,6 @@ encoder_traverse(PyObject *op, visitproc visit, void *arg)
18381762{
18391763 PyEncoderObject * self = PyEncoderObject_CAST (op );
18401764 Py_VISIT (Py_TYPE (self ));
1841- Py_VISIT (self -> markers );
18421765 Py_VISIT (self -> defaultfn );
18431766 Py_VISIT (self -> encoder );
18441767 Py_VISIT (self -> indent );
@@ -1852,7 +1775,6 @@ encoder_clear(PyObject *op)
18521775{
18531776 PyEncoderObject * self = PyEncoderObject_CAST (op );
18541777 /* Deallocate Encoder */
1855- Py_CLEAR (self -> markers );
18561778 Py_CLEAR (self -> defaultfn );
18571779 Py_CLEAR (self -> encoder );
18581780 Py_CLEAR (self -> indent );
0 commit comments