[pypy-svn] pypy default: Fix translation (hopefully), also fix semantics. Double win!
alex_gaynor
commits-noreply at bitbucket.org
Sat Jan 29 07:31:39 CET 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r41439:da6d343d720a
Date: 2011-01-29 01:31 -0500
http://bitbucket.org/pypy/pypy/changeset/da6d343d720a/
Log: Fix translation (hopefully), also fix semantics. Double win!
diff --git a/pypy/module/_io/test/test_stringio.py b/pypy/module/_io/test/test_stringio.py
--- a/pypy/module/_io/test/test_stringio.py
+++ b/pypy/module/_io/test/test_stringio.py
@@ -49,6 +49,9 @@
assert r == s[3:]
raises(TypeError, sio.seek, 0.0)
+ exc_info = raises(ValueError, sio.seek, -3)
+ assert exc_info.value.args[0] == "negative seek position: -3"
+
def test_write_error(self):
import io
@@ -57,4 +60,4 @@
sio = io.StringIO(u"")
exc_info = raises(TypeError, sio.write, 3)
- assert "int" in exc_info.value.args[0]
\ No newline at end of file
+ assert "int" in exc_info.value.args[0]
diff --git a/pypy/module/_io/interp_stringio.py b/pypy/module/_io/interp_stringio.py
--- a/pypy/module/_io/interp_stringio.py
+++ b/pypy/module/_io/interp_stringio.py
@@ -76,6 +76,10 @@
@unwrap_spec('self', ObjSpace, int)
def seek_w(self, space, pos):
+ if pos < 0:
+ raise operationerrfmt(space.w_ValueError,
+ "negative seek position: %d", pos
+ )
self.pos = pos
@unwrap_spec('self', ObjSpace)
@@ -116,4 +120,3 @@
close = interp2app(W_StringIO.close_w),
closed = GetSetProperty(W_StringIO.closed_get_w),
)
-
More information about the Pypy-commit
mailing list