summaryrefslogtreecommitdiff
path: root/tests/io/bytesio_ext2.py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-08-20 21:57:36 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-08-20 22:02:41 +0300
commite3383e9352ca7704e650b07038207719c60b56fb (patch)
tree92ed2d9aab2ef2046ffd913b77309cf515236a63 /tests/io/bytesio_ext2.py
parent0cd9ab77550eada4def492a3a25286ead71a3b24 (diff)
py/stream: seek: Consistently handle negative offset for SEEK_SET.
Per POSIX, this is EINVAL, so raises OSError(EINVAL).
Diffstat (limited to 'tests/io/bytesio_ext2.py')
-rw-r--r--tests/io/bytesio_ext2.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/io/bytesio_ext2.py b/tests/io/bytesio_ext2.py
new file mode 100644
index 000000000..c07ad900c
--- /dev/null
+++ b/tests/io/bytesio_ext2.py
@@ -0,0 +1,13 @@
+try:
+ import uio as io
+except ImportError:
+ import io
+
+a = io.BytesIO(b"foobar")
+try:
+ a.seek(-10)
+except Exception as e:
+ # CPython throws ValueError, but MicroPython has consistent stream
+ # interface, so BytesIO raises the same error as a real file, which
+ # is OSError(EINVAL).
+ print(repr(e))