Author: Brian Kearns <[email protected]>
Branch: stdlib-2.7.4
Changeset: r63195:f0ec8a1cddcf
Date: 2013-04-10 02:42 -0400
http://bitbucket.org/pypy/pypy/changeset/f0ec8a1cddcf/
Log: fix fileio testUnclosedFDOnException
diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py
--- a/pypy/module/_io/interp_fileio.py
+++ b/pypy/module/_io/interp_fileio.py
@@ -179,7 +179,7 @@
fd_is_own = True
self._dircheck(space, w_name)
- self.w_name = w_name
+ space.setattr(self, space.wrap("name"), w_name)
if append:
# For consistent behaviour, we explicitly seek to the end of
file
diff --git a/pypy/module/_io/test/test_fileio.py
b/pypy/module/_io/test/test_fileio.py
--- a/pypy/module/_io/test/test_fileio.py
+++ b/pypy/module/_io/test/test_fileio.py
@@ -165,6 +165,19 @@
f.close()
assert repr(f) == "<_io.FileIO [closed]>"
+ def test_unclosed_fd_on_exception(self):
+ import _io
+ import os
+ class MyException(Exception): pass
+ class MyFileIO(_io.FileIO):
+ def __setattr__(self, name, value):
+ if name == "name":
+ raise MyException("blocked setting name")
+ return super(MyFileIO, self).__setattr__(name, value)
+ fd = os.open(self.tmpfile, os.O_RDONLY)
+ raises(MyException, MyFileIO, fd)
+ os.close(fd) # should not raise OSError(EBADF)
+
def test_flush_at_exit():
from pypy import conftest
from pypy.tool.option import make_config, make_objspace
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit