Skip to content

Commit

Permalink
pythongh-94808: Fix refcounting in PyObject_Print tests
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou committed Apr 1, 2024
1 parent dd44ab9 commit abea62c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Modules/_testcapi/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ pyobject_print_noref_object(PyObject *self, PyObject *args)

if (PyObject_Print(test_string, fp, 0) < 0){
fclose(fp);
Py_SET_REFCNT(test_string, 1);
Py_DECREF(test_string);
return NULL;
}

Expand Down Expand Up @@ -105,10 +107,12 @@ pyobject_print_os_error(PyObject *self, PyObject *args)

if (PyObject_Print(test_string, fp, 0) < 0) {
fclose(fp);
Py_DECREF(test_string);
return NULL;
}

fclose(fp);
Py_DECREF(test_string);

Py_RETURN_NONE;
}
Expand Down

0 comments on commit abea62c

Please sign in to comment.