Skip to content

Commit

Permalink
pythongh-94808: Fix refcounting in PyObject_Print tests (pythonGH-117421
Browse files Browse the repository at this point in the history
)
  • Loading branch information
encukou authored and diegorusso committed Apr 17, 2024
1 parent 904ecd8 commit c10c7ad
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 c10c7ad

Please sign in to comment.