[pypy-svn] r61076 - in pypy/trunk/pypy/module/_file: . test
fijal at codespeak.net
fijal at codespeak.net
Sun Jan 18 12:22:51 CET 2009
Author: fijal
Date: Sun Jan 18 12:22:48 2009
New Revision: 61076
Modified:
pypy/trunk/pypy/module/_file/interp_file.py
pypy/trunk/pypy/module/_file/test/test_file.py
Log:
A test and a fix for forbidden modes (explicitely by PEP 278 according
to cpython's source)
Modified: pypy/trunk/pypy/module/_file/interp_file.py
==============================================================================
--- pypy/trunk/pypy/module/_file/interp_file.py (original)
+++ pypy/trunk/pypy/module/_file/interp_file.py Sun Jan 18 12:22:48 2009
@@ -49,7 +49,8 @@
getopenstreams(self.space)[stream] = None
def check_mode_ok(self, mode):
- if not mode or mode[0] not in ['r', 'w', 'a', 'U']:
+ if (not mode or mode[0] not in ['r', 'w', 'a', 'U'] or
+ ('U' in mode and ('w' in mode or 'a' in mode))):
space = self.space
raise OperationError(space.w_ValueError,
space.wrap('invalid mode : "%s"' % mode))
Modified: pypy/trunk/pypy/module/_file/test/test_file.py
==============================================================================
--- pypy/trunk/pypy/module/_file/test/test_file.py (original)
+++ pypy/trunk/pypy/module/_file/test/test_file.py Sun Jan 18 12:22:48 2009
@@ -149,6 +149,11 @@
assert f.read(12L) == 'From: foo\n\n0'
f.close()
+ def test_invalid_modes(self):
+ raises(ValueError, self.file, self.temppath, "aU")
+ raises(ValueError, self.file, self.temppath, "wU+")
+ raises(ValueError, self.file, self.temppath, "")
+
class AppTestConcurrency(object):
# these tests only really make sense on top of a translated pypy-c,
# because on top of py.py the inner calls to os.write() don't
More information about the Pypy-commit
mailing list