io_bytesio_ext2.py 334 B

12345678910111213
  1. try:
  2. import uio as io
  3. except ImportError:
  4. import io
  5. a = io.BytesIO(b"foobar")
  6. try:
  7. a.seek(-10)
  8. except Exception as e:
  9. # CPython throws ValueError, but MicroPython has consistent stream
  10. # interface, so BytesIO raises the same error as a real file, which
  11. # is OSError(EINVAL).
  12. print(type(e), e.args[0] > 0)