Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-94808:Improve coverage of PyObject_Print #98749

Merged
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
Loading