summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/private/npy_3kcompat.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/numpy/core/src/private/npy_3kcompat.h b/numpy/core/src/private/npy_3kcompat.h
index b7df15294..30154b03f 100644
--- a/numpy/core/src/private/npy_3kcompat.h
+++ b/numpy/core/src/private/npy_3kcompat.h
@@ -138,6 +138,11 @@ npy_PyFile_Dup(PyObject *file, char *mode)
{
int fd, fd2;
PyObject *ret, *os;
+ /* Flush first to ensure things end up in the file in the correct order */
+ ret = PyObject_CallMethod(file, "flush", "");
+ if (ret == NULL) {
+ return NULL;
+ }
fd = PyObject_AsFileDescriptor(file);
if (fd == -1) {
return NULL;