Author: Matti Picus <matti.pi...@gmail.com> Branch: Changeset: r70348:7ccee921d146 Date: 2014-03-31 15:30 +0300 http://bitbucket.org/pypy/pypy/changeset/7ccee921d146/
Log: a failing test, and the simplest possible fix diff --git a/pypy/module/_file/test/test_file.py b/pypy/module/_file/test/test_file.py --- a/pypy/module/_file/test/test_file.py +++ b/pypy/module/_file/test/test_file.py @@ -254,6 +254,13 @@ if '__pypy__' in sys.builtin_module_names: assert repr(self.temppath) in g.getvalue() + def test_truncate(self): + f = self.file(self.temppath, "w") + f.write("foo") + f.close() + with self.file(self.temppath, 'r') as f: + raises(IOError, f.truncate, 100) + class AppTestNonblocking(object): def setup_class(cls): diff --git a/rpython/rlib/streamio.py b/rpython/rlib/streamio.py --- a/rpython/rlib/streamio.py +++ b/rpython/rlib/streamio.py @@ -193,7 +193,7 @@ # Truncate. Note that this may grow the file! handle = get_osfhandle(fd) if not SetEndOfFile(handle): - raise WindowsError(GetLastError(), + raise OSError(GetLastError(), "Could not truncate file") finally: # we restore the file pointer position in any case _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit