Issue #5700: io.FileIO() called flush() after closing the file.
flush() was not called in close() if closefd=False.
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 @@
 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 *