summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-10-30 23:16:28 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-10-30 23:16:28 (GMT)
commitbbb0412ad179b4a94d03ce592a5bc1d40724998e (patch)
tree9abca71d3292a61bd79197552737d5d0518df2e1
parent430d469758a7a5574409f06431b8596261d62893 (diff)
downloadcpython-bbb0412ad179b4a94d03ce592a5bc1d40724998e.zip
cpython-bbb0412ad179b4a94d03ce592a5bc1d40724998e.tar.gz
cpython-bbb0412ad179b4a94d03ce592a5bc1d40724998e.tar.bz2
if FileIO.__init__ fails, close fd
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_io/fileio.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index cadafd0..21dcacf 100644
--- 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).
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 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
error:
ret = -1;
+ if (self->fd >= 0)
+ internal_close(self);
done:
Py_CLEAR(stringobj);