summaryrefslogtreecommitdiffstats
path: root/Modules/_io/fileio.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-10-31 13:05:21 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-10-31 13:05:21 (GMT)
commit735e3b195a492d7480572f3c29fd4ef7d8723266 (patch)
treed457af550f88c7460b5d117d02c64661fc0fe77e /Modules/_io/fileio.c
parentd9f3f08b8cdf08bc83af9c9ac2709a583f73d5db (diff)
downloadcpython-735e3b195a492d7480572f3c29fd4ef7d8723266.zip
cpython-735e3b195a492d7480572f3c29fd4ef7d8723266.tar.gz
cpython-735e3b195a492d7480572f3c29fd4ef7d8723266.tar.bz2
Merged revisions 85982 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85982 | antoine.pitrou | 2010-10-30 18:19:14 +0200 (sam., 30 oct. 2010) | 4 lines Issue #10253: FileIO leaks a file descriptor when trying to open a file for append that isn't seekable. Patch by Brian Brazil. ........
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r--Modules/_io/fileio.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index f332ee4..a365c9f 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -364,8 +364,13 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
end of file (otherwise, it might be done only on the
first write()). */
PyObject *pos = portable_lseek(self->fd, NULL, 2);
- if (pos == NULL)
+ if (pos == NULL) {
+ if (closefd) {
+ close(self->fd);
+ self->fd = -1;
+ }
goto error;
+ }
Py_DECREF(pos);
}