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
Close file when error is returned
  • Loading branch information
MonadChains committed Oct 28, 2022
commit 25c24e4e724680b438e78e2e40498c9688c737bd
4 changes: 4 additions & 0 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,7 @@ call_pyobject_print(PyObject *self, PyObject * args)
}

if (PyObject_Print(object, fp, flags) < 0) {
fclose(fp);
return NULL;
}

Expand All @@ -2042,6 +2043,7 @@ pyobject_print_null(PyObject *self, PyObject *args)
fp = _Py_fopen_obj(filename, "w+");

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

Expand Down Expand Up @@ -2071,6 +2073,7 @@ pyobject_print_noref_object(PyObject *self, PyObject *args)
fp = _Py_fopen_obj(filename, "w+");

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

Expand All @@ -2096,6 +2099,7 @@ pyobject_print_os_error(PyObject *self, PyObject *args)
fp = _Py_fopen_obj(filename, "r");

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

Expand Down