Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5262887

Browse files
committed
improve ref counting
1 parent 22ecb23 commit 5262887

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Modules/pyexpat.c

+4-9
Original file line numberDiff line numberDiff line change
@@ -1867,21 +1867,16 @@ pyexpat_exec(PyObject *mod)
18671867

18681868
/* Add some symbolic constants to the module */
18691869

1870-
Py_INCREF(state->error);
1871-
if (PyModule_AddObject(mod, "error", state->error) < 0) {
1872-
Py_DECREF(state->error);
1870+
if (PyModule_AddObjectRef(mod, "error", state->error) < 0) {
18731871
return -1;
18741872
}
1875-
Py_INCREF(state->error);
1876-
if (PyModule_AddObject(mod, "ExpatError", state->error) < 0) {
1877-
Py_DECREF(state->error);
1873+
1874+
if (PyModule_AddObjectRef(mod, "ExpatError", state->error) < 0) {
18781875
return -1;
18791876
}
18801877

1881-
Py_INCREF(state->xml_parse_type);
1882-
if (PyModule_AddObject(mod, "XMLParserType",
1878+
if (PyModule_AddObjectRef(mod, "XMLParserType",
18831879
(PyObject *) state->xml_parse_type) < 0) {
1884-
Py_DECREF(state->xml_parse_type);
18851880
return -1;
18861881
}
18871882

0 commit comments

Comments
 (0)