diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:15:51 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:15:51 +0000 |
commit | e247b1d3d3a93b5119524ce6306239415e89ae74 (patch) | |
tree | 9d11144c2c177886f16f17a6f76552f102a99ecd | |
parent | ff26cec7eba491cf4cf48542b21f44932baf9572 (diff) | |
download | numpy-e247b1d3d3a93b5119524ce6306239415e89ae74.tar.gz |
3K: core: in tofile etc., ensure the file is flushed before switching to FILE* I/O
-rw-r--r-- | numpy/core/src/private/npy_3kcompat.h | 5 |
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; |