if FileIO.__init__ fails, close fd
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 37ff25c..09ea80f 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -410,6 +410,8 @@
 
  error:
     ret = -1;
+    if (self->fd >= 0)
+        internal_close(self);
 
  done:
     Py_CLEAR(stringobj);