[Python-checkins] r85982 - in python/branches/py3k: Lib/test/test_fileio.py Misc/NEWS Modules/_io/fileio.c
antoine.pitrou
python-checkins at python.org
Sat Oct 30 18:19:14 CEST 2010
Author: antoine.pitrou
Date: Sat Oct 30 18:19:14 2010
New Revision: 85982
Log:
Issue #10253: FileIO leaks a file descriptor when trying to open a file
for append that isn't seekable. Patch by Brian Brazil.
Modified:
python/branches/py3k/Lib/test/test_fileio.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Modules/_io/fileio.c
Modified: python/branches/py3k/Lib/test/test_fileio.py
==============================================================================
--- python/branches/py3k/Lib/test/test_fileio.py (original)
+++ python/branches/py3k/Lib/test/test_fileio.py Sat Oct 30 18:19:14 2010
@@ -339,6 +339,7 @@
f.truncate(15)
self.assertEqual(f.tell(), 5)
self.assertEqual(f.seek(0, os.SEEK_END), 15)
+ f.close()
def testTruncateOnWindows(self):
def bug801631():
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sat Oct 30 18:19:14 2010
@@ -57,6 +57,9 @@
Library
-------
+- Issue #10253: FileIO leaks a file descriptor when trying to open a file
+ for append that isn't seekable. Patch by Brian Brazil.
+
- Support context manager protocol for file-like objects returned by
mailbox ``get_file()`` methods.
Modified: python/branches/py3k/Modules/_io/fileio.c
==============================================================================
--- python/branches/py3k/Modules/_io/fileio.c (original)
+++ python/branches/py3k/Modules/_io/fileio.c Sat Oct 30 18:19:14 2010
@@ -396,8 +396,13 @@
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);
}
More information about the Python-checkins
mailing list