Commit 594a046b authored by Antoine Pitrou's avatar Antoine Pitrou

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.
........
parent e27731d0
...@@ -341,6 +341,7 @@ class OtherFileTests(unittest.TestCase): ...@@ -341,6 +341,7 @@ class OtherFileTests(unittest.TestCase):
f.truncate(15) f.truncate(15)
self.assertEqual(f.tell(), 5) self.assertEqual(f.tell(), 5)
self.assertEqual(f.seek(0, os.SEEK_END), 15) self.assertEqual(f.seek(0, os.SEEK_END), 15)
f.close()
def testTruncateOnWindows(self): def testTruncateOnWindows(self):
def bug801631(): def bug801631():
......
...@@ -66,6 +66,9 @@ Core and Builtins ...@@ -66,6 +66,9 @@ Core and Builtins
Library Library
------- -------
- Issue #10253: FileIO leaks a file descriptor when trying to open a file
for append that isn't seekable. Patch by Brian Brazil.
- Issue #6105: json.dumps now respects OrderedDict's iteration order. - Issue #6105: json.dumps now respects OrderedDict's iteration order.
- Issue #9295: Fix a crash under Windows when calling close() on a file - Issue #9295: Fix a crash under Windows when calling close() on a file
......
...@@ -367,8 +367,13 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) ...@@ -367,8 +367,13 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
end of file (otherwise, it might be done only on the end of file (otherwise, it might be done only on the
first write()). */ first write()). */
PyObject *pos = portable_lseek(self->fd, NULL, 2); PyObject *pos = portable_lseek(self->fd, NULL, 2);
if (pos == NULL) if (pos == NULL) {
if (closefd) {
close(self->fd);
self->fd = -1;
}
goto error; goto error;
}
Py_DECREF(pos); Py_DECREF(pos);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment