Skip to content
Prev Previous commit
Next Next commit
Use PyModule_AddObjectRef
  • Loading branch information
Erlend E. Aasland committed Jan 11, 2021
commit 404b398d69313a941b1dae753613f8066f00f4bd
5 changes: 3 additions & 2 deletions Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -4366,7 +4366,9 @@ PyInit__elementtree(void)
"xml.etree.ElementTree.ParseError", PyExc_SyntaxError, NULL
);
Py_INCREF(st->parseerror_obj);
if (PyModule_AddObject(m, "ParseError", st->parseerror_obj) < 0) {
int res = PyModule_AddObjectRef(m, "ParseError", st->parseerror_obj);
Py_DECREF(st->parseerror_obj);
if (res < 0) {
goto error;
}

Expand All @@ -4385,7 +4387,6 @@ PyInit__elementtree(void)
return m;

error:
Py_XDECREF(st->parseerror_obj);
Py_XDECREF(m);
return NULL;
}