]> granicus.if.org Git - python/commitdiff
if FileIO.__init__ fails, close fd
authorBenjamin Peterson <benjamin@python.org>
Sat, 30 Oct 2010 23:16:28 +0000 (23:16 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 30 Oct 2010 23:16:28 +0000 (23:16 +0000)
Misc/NEWS
Modules/_io/fileio.c

index cadafd02b0864a17393638654cd0dd4d33c4b4f5..21dcacfdb810be2e7678e7f444ff7ca05cc5ec4d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.2 Beta 1?
 Core and Builtins
 -----------------
 
+- If FileIO.__init__ fails, close the file descriptor.
+
 - Issue #10221: dict.pop(k) now has a key error message that includes the
   missing key (same message d[k] returns for missing keys).
 
index 37ff25c495dd59045d0e75443be7ee5aff3e1f02..09ea80f179df1a14f3ce5a0dd9473af970bec134 100644 (file)
@@ -410,6 +410,8 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
 
  error:
     ret = -1;
+    if (self->fd >= 0)
+        internal_close(self);
 
  done:
     Py_CLEAR(stringobj);