gh-109611: Add convenient C API function _PyFile_Flush() (GH-109612)

This commit is contained in:
Serhiy Storchaka 2023-09-23 09:35:30 +03:00 committed by GitHub
parent 92af0cc580
commit b8d1744e7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 54 additions and 97 deletions

View file

@ -1513,11 +1513,9 @@ write_unraisable_exc_file(PyThreadState *tstate, PyObject *exc_type,
}
/* Explicitly call file.flush() */
PyObject *res = PyObject_CallMethodNoArgs(file, &_Py_ID(flush));
if (!res) {
if (_PyFile_Flush(file) < 0) {
return -1;
}
Py_DECREF(res);
return 0;
}