Skip to content

Commit a9c895e

Browse files
committed
simplify error path cleanup
1 parent 81332c7 commit a9c895e

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

Modules/_json.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,15 +1633,9 @@ encoder_listencode_obj(PyEncoderObject *s, PyUnicodeWriter *writer,
16331633

16341634
if (_Py_EnterRecursiveCall(" while encoding a JSON object")) {
16351635
if (ident != NULL) {
1636-
int del_rv = PyDict_DelItem(s->markers, ident);
1637-
Py_DECREF(ident);
1638-
if (del_rv < 0) {
1639-
Py_DECREF(newobj);
1640-
return -1;
1641-
}
1642-
1636+
(void)PyDict_DelItem(s->markers, ident);
16431637
}
1644-
1638+
Py_XDECREF(ident);
16451639
Py_DECREF(newobj);
16461640
return -1;
16471641
}
@@ -1652,20 +1646,17 @@ encoder_listencode_obj(PyEncoderObject *s, PyUnicodeWriter *writer,
16521646
if (rv) {
16531647
_PyErr_FormatNote("when serializing %T object", obj);
16541648
if (ident != NULL) {
1655-
int del_rv = PyDict_DelItem(s->markers, ident);
1656-
Py_DECREF(ident);
1657-
if (del_rv < 0) {
1658-
return -1;
1659-
}
1649+
(void)PyDict_DelItem(s->markers, ident);
16601650
}
1651+
Py_XDECREF(ident);
16611652
return -1;
16621653
}
16631654
if (ident != NULL) {
1664-
int del_rv = PyDict_DelItem(s->markers, ident);
1665-
Py_DECREF(ident);
1666-
if (del_rv < 0) {
1655+
if (PyDict_DelItem(s->markers, ident)) {
1656+
Py_DECREF(ident);
16671657
return -1;
16681658
}
1659+
Py_XDECREF(ident);
16691660
}
16701661
return rv;
16711662
}

0 commit comments

Comments
 (0)