[pypy-svn] r38719 - in pypy/dist/pypy/module/_file: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue Feb 13 17:18:30 CET 2007
Author: cfbolz
Date: Tue Feb 13 17:18:30 2007
New Revision: 38719
Modified:
pypy/dist/pypy/module/_file/app_file.py
pypy/dist/pypy/module/_file/test/test_file.py
Log:
another one of those
Modified: pypy/dist/pypy/module/_file/app_file.py
==============================================================================
--- pypy/dist/pypy/module/_file/app_file.py (original)
+++ pypy/dist/pypy/module/_file/app_file.py Tue Feb 13 17:18:30 2007
@@ -131,6 +131,8 @@
total number of bytes in the lines returned."""
if self._closed:
raise ValueError('I/O operation on closed file')
+ if not isinstance(size, (int, long)):
+ raise TypeError("an integer is required")
if size < 0:
return list(iter(self.stream.readline, ""))
else:
Modified: pypy/dist/pypy/module/_file/test/test_file.py
==============================================================================
--- pypy/dist/pypy/module/_file/test/test_file.py (original)
+++ pypy/dist/pypy/module/_file/test/test_file.py Tue Feb 13 17:18:30 2007
@@ -40,6 +40,22 @@
finally:
f.close()
+ def test_readlines(self):
+ import _file
+ f = _file.file(self.temppath, "w")
+ try:
+ f.write("foo\nbar\n")
+ finally:
+ f.close()
+ f = _file.file(self.temppath, "r")
+ raises(TypeError, f.readlines, None)
+ try:
+ s = f.readlines()
+ assert s == ["foo\n", "bar\n"]
+ finally:
+ f.close()
+
+
def test_fdopen(self):
import _file, os
f = _file.file(self.temppath, "w")
More information about the Pypy-commit
mailing list