Skip to content

mpremote: Unknown errno.ENOTBLK on Windows #17773

@Josverl

Description

@Josverl

Port, board and/or hardware

any

MicroPython version

Mpremote v1.26.0-preview

Reproduction

Try to start (any) mpremote command on windows.
Mpremote will error out before starting ( see example stacktrace below)

@dpgeorge
Introduced in : 05342b0

Expected behaviour

No stacktrace

Observed behaviour

 mpremote connect COM8 resume exec "print(x)"
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\mypython\micropython\.venv\Scripts\mpremote.exe\__main__.py", line 4, in <module>
    from mpremote.main import main
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\mypython\micropython\.venv\Scripts\mpremote.exe\__main__.py", line 4, in <module>
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
Traceback (most recent call last):
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\mypython\micropython\.venv\Scripts\mpremote.exe\__main__.py", line 4, in <module>
    from mpremote.main import main
  File "D:\mypython\micropython\tools\mpremote\mpremote\main.py", line 25, in <module>
    from .commands import (
    ...<14 lines>...
    )
  File "D:\mypython\micropython\tools\mpremote\mpremote\commands.py", line 11, in <module>
    from .transport import TransportError, TransportExecError, stdout_write_bytes
  File "D:\mypython\micropython\tools\mpremote\mpremote\transport.py", line 29, in <module>
    from .mp_errno import MP_ERRNO_TABLE
  File "D:\mypython\micropython\tools\mpremote\mpremote\mp_errno.py", line 19, in <module>
    15: errno.ENOTBLK,
        ^^^^^^^^^^^^^
AttributeError: module 'errno' has no attribute 'ENOTBLK'. Did you mean: 'ENOTSOCK'?

Additional Information

Windows doesn’t use the same device classification system as Unix-like OSes. It doesn't differentiate between block and character devices in the same way, so the concept of a "block device" doesn’t map directly. Because of that, Windows’ version of the errno list omits ENOTBLK.

Likely this list needs to be built taking the platform into account, and/or wrapped in appropriate error handling.

if platform.system() != "Windows":
    MP_ERRNO_TABLE[15] = errno.ENOTBLK

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtoolsRelates to tools/ directory in source, or other tooling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions