diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-08-20 21:57:36 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-08-20 22:02:41 +0300 |
commit | e3383e9352ca7704e650b07038207719c60b56fb (patch) | |
tree | 92ed2d9aab2ef2046ffd913b77309cf515236a63 /tests | |
parent | 0cd9ab77550eada4def492a3a25286ead71a3b24 (diff) | |
download | micropython-e3383e9352ca7704e650b07038207719c60b56fb.tar.gz micropython-e3383e9352ca7704e650b07038207719c60b56fb.zip |
py/stream: seek: Consistently handle negative offset for SEEK_SET.
Per POSIX, this is EINVAL, so raises OSError(EINVAL).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/io/bytesio_ext2.py | 13 | ||||
-rw-r--r-- | tests/io/bytesio_ext2.py.exp | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/io/bytesio_ext2.py b/tests/io/bytesio_ext2.py new file mode 100644 index 0000000000..c07ad900c9 --- /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)) diff --git a/tests/io/bytesio_ext2.py.exp b/tests/io/bytesio_ext2.py.exp new file mode 100644 index 0000000000..b52e4978aa --- /dev/null +++ b/tests/io/bytesio_ext2.py.exp @@ -0,0 +1 @@ +OSError(22,) |