summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-09-23 06:35:30 (GMT)
committerGitHub <noreply@github.com>2023-09-23 06:35:30 (GMT)
commitb8d1744e7ba87a4057350fdfd788b5621095fc59 (patch)
tree367ba89c2a83a1115f74b1e0c83384e047ef4b84 /Objects
parent92af0cc580051fd1129c7a86af2cbadeb2aa36dc (diff)
downloadcpython-b8d1744e7ba87a4057350fdfd788b5621095fc59.zip
cpython-b8d1744e7ba87a4057350fdfd788b5621095fc59.tar.gz
cpython-b8d1744e7ba87a4057350fdfd788b5621095fc59.tar.bz2
gh-109611: Add convenient C API function _PyFile_Flush() (GH-109612)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 9c24025..0cf2b47 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -529,6 +529,18 @@ PyFile_OpenCode(const char *utf8path)
}
+int
+_PyFile_Flush(PyObject *file)
+{
+ PyObject *tmp = PyObject_CallMethodNoArgs(file, &_Py_ID(flush));
+ if (tmp == NULL) {
+ return -1;
+ }
+ Py_DECREF(tmp);
+ return 0;
+}
+
+
#ifdef __cplusplus
}
#endif