Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r60919:f8a6a39cdb36
Date: 2013-02-06 15:29 -0800
http://bitbucket.org/pypy/pypy/changeset/f8a6a39cdb36/
Log: IOError -> UnsupportedOperation
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -809,8 +809,7 @@
self._check_closed(space)
if not self.seekable:
- raise OperationError(space.w_IOError, space.wrap(
- "underlying stream is not seekable"))
+ self._unsupportedoperation("underlying stream is not seekable")
if whence == 1:
# seek relative to current position
@@ -888,8 +887,7 @@
self._check_closed(space)
if not self.seekable:
- raise OperationError(space.w_IOError, space.wrap(
- "underlying stream is not seekable"))
+ self._unsupportedoperation("underlying stream is not seekable")
if not self.telling:
raise OperationError(space.w_IOError, space.wrap(
diff --git a/pypy/module/_io/test/test_bufferedio.py
b/pypy/module/_io/test/test_bufferedio.py
--- a/pypy/module/_io/test/test_bufferedio.py
+++ b/pypy/module/_io/test/test_bufferedio.py
@@ -214,6 +214,19 @@
assert r == b"abca"
assert rawio.count == 4
+ def test_unseekable(self):
+ import _io
+ class Unseekable(_io.BytesIO):
+ def seekable(self):
+ return False
+ def seek(self, *args):
+ raise _io.UnsupportedOperation("not seekable")
+ def tell(self, *args):
+ raise _io.UnsupportedOperation("not seekable")
+ bufio = _io.BufferedReader(Unseekable())
+ raises(_io.UnsupportedOperation, bufio.tell)
+ raises(_io.UnsupportedOperation, bufio.seek, 0)
+
class AppTestBufferedReaderWithThreads(AppTestBufferedReader):
spaceconfig = dict(usemodules=['_io', 'thread'])
diff --git a/pypy/module/_io/test/test_textio.py
b/pypy/module/_io/test/test_textio.py
--- a/pypy/module/_io/test/test_textio.py
+++ b/pypy/module/_io/test/test_textio.py
@@ -42,6 +42,15 @@
txt = _io.TextIOWrapper(UnReadable())
raises(IOError, txt.read)
+ def test_unseekable(self):
+ import _io
+ class Unseekable(_io.BytesIO):
+ def seekable(self):
+ return False
+ txt = _io.TextIOWrapper(Unseekable())
+ raises(_io.UnsupportedOperation, txt.tell)
+ raises(_io.UnsupportedOperation, txt.seek, 0)
+
def test_detach(self):
import _io
b = _io.BytesIO()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit