diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-20 22:34:20 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-20 22:34:20 (GMT) |
commit | 3173f7c904c057f22642d570a4be2694cacd5b15 (patch) | |
tree | 8e0d609a0fa5d24d18c2cb258468b2acad420653 /Modules/_io/fileio.c | |
parent | dc9d41d71820b255ba21683578aac7c9129cf0ce (diff) | |
download | cpython-3173f7c904c057f22642d570a4be2694cacd5b15.zip cpython-3173f7c904c057f22642d570a4be2694cacd5b15.tar.gz cpython-3173f7c904c057f22642d570a4be2694cacd5b15.tar.bz2 |
Issue #5700: io.FileIO() called flush() after closing the file.
flush() was not called in close() if closefd=False.
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r-- | Modules/_io/fileio.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 94f62d0..5404f5d 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -101,16 +101,16 @@ internal_close(fileio *self) static PyObject * fileio_close(fileio *self) { + PyObject *res; + res = PyObject_CallMethod((PyObject*)&PyRawIOBase_Type, + "close", "O", self); if (!self->closefd) { self->fd = -1; - Py_RETURN_NONE; + return res; } - errno = internal_close(self); - if (errno < 0) - return NULL; - - return PyObject_CallMethod((PyObject*)&PyRawIOBase_Type, - "close", "O", self); + if (internal_close(self) < 0) + Py_CLEAR(res); + return res; } static PyObject * |