From e247b1d3d3a93b5119524ce6306239415e89ae74 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 20 Feb 2010 18:15:51 +0000 Subject: 3K: core: in tofile etc., ensure the file is flushed before switching to FILE* I/O --- numpy/core/src/private/npy_3kcompat.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'numpy/core/src') 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; -- cgit v1.2.1