[pypy-svn] r34199 - in pypy/branch/refactor-file/pypy/module/_file: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Sat Nov 4 17:47:12 CET 2006
Author: cfbolz
Date: Sat Nov 4 17:47:10 2006
New Revision: 34199
Modified:
pypy/branch/refactor-file/pypy/module/_file/app_file.py
pypy/branch/refactor-file/pypy/module/_file/interp_file.py
pypy/branch/refactor-file/pypy/module/_file/test/test_file.py
Log:
(guido, cfbolz): fix another error path, and make __del__ not fail if the
object was constructed with __new__ but not __init__ialized.
Modified: pypy/branch/refactor-file/pypy/module/_file/app_file.py
==============================================================================
--- pypy/branch/refactor-file/pypy/module/_file/app_file.py (original)
+++ pypy/branch/refactor-file/pypy/module/_file/app_file.py Sat Nov 4 17:47:10 2006
@@ -211,7 +211,7 @@
further I/O operations. close() may be called more than once without
error. Some kinds of file objects (for example, opened by popen())
may return an exit status upon closing."""
- if not self._closed:
+ if not self._closed and hasattr(self, 'stream'):
self._closed = True
self.stream.close()
Modified: pypy/branch/refactor-file/pypy/module/_file/interp_file.py
==============================================================================
--- pypy/branch/refactor-file/pypy/module/_file/interp_file.py (original)
+++ pypy/branch/refactor-file/pypy/module/_file/interp_file.py Sat Nov 4 17:47:10 2006
@@ -73,7 +73,7 @@
return space.wrap(W_Stream(
space, streamio.open_file_as_stream(path, mode, buffering)))
except OSError, e:
- raise wrap_oserror_as_ioerror(e)
+ raise wrap_oserror_as_ioerror(space, e)
open_file_as_stream.unwrap_spec = [ObjSpace, str, str, int]
def fdopen_as_stream(space, fd, mode="r", buffering=-1):
Modified: pypy/branch/refactor-file/pypy/module/_file/test/test_file.py
==============================================================================
--- pypy/branch/refactor-file/pypy/module/_file/test/test_file.py (original)
+++ pypy/branch/refactor-file/pypy/module/_file/test/test_file.py Sat Nov 4 17:47:10 2006
@@ -45,3 +45,7 @@
def test_badmode(self):
import _file
raises(IOError, _file.file, "foo", "bar")
+
+ def test_wraposerror(self):
+ import _file
+ raises(IOError, _file.file, "hopefully/not/existant.bar")
More information about the Pypy-commit
mailing list