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
Rework negative reference test
  • Loading branch information
MonadChains committed Nov 1, 2022
commit 2202e4a6dea2afb2ae1fe5025c3cb026bd525411
5 changes: 4 additions & 1 deletion Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2062,7 +2062,7 @@ pyobject_print_noref_object(PyObject *self, PyObject *args)

test_string = PyUnicode_FromString("Spam spam spam");

Py_DECREF(test_string);
test_string -> ob_refcnt = 0;

snprintf(correct_string, 100, "<refcnt %zd at %p>", Py_REFCNT(test_string), (void *)test_string);

Expand All @@ -2079,6 +2079,9 @@ pyobject_print_noref_object(PyObject *self, PyObject *args)

fclose(fp);

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

return PyUnicode_FromString(correct_string);
}

Expand Down