Skip to content
Prev Previous commit
Next Next commit
Use Py_SET_REFCNT rather than ob_refcnt
  • Loading branch information
encukou committed Mar 25, 2024
commit 355e8e43102c3fc8a04e60b51e4df37a6fc89caf
4 changes: 2 additions & 2 deletions Modules/_testcapi/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pyobject_print_noref_object(PyObject *self, PyObject *args)

test_string = PyUnicode_FromString("Spam spam spam");

test_string->ob_refcnt = 0;
Py_SET_REFCNT(test_string, 0);

PyOS_snprintf(correct_string, 100, "<refcnt %zd at %p>",
Py_REFCNT(test_string), (void *)test_string);
Expand All @@ -81,7 +81,7 @@ pyobject_print_noref_object(PyObject *self, PyObject *args)

fclose(fp);

test_string->ob_refcnt = 1;
Py_SET_REFCNT(test_string, 1);
Py_DECREF(test_string);

return PyUnicode_FromString(correct_string);
Expand Down