9f1eafc380
If MICROPY_USE_INTERNAL_ERRNO is disabled, MP_EINVAL is not guaranteed to have the value 22, so we cannot depend on OSError(22,). Instead, to support any given port's errno values, without relying on uerrno, we just check that the args[0] is positive.
14 lines
334 B
Python
14 lines
334 B
Python
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(type(e), e.args[0] > 0)
|