Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errno.EROFS isn't available but its error string is #9733

Closed
ricknun opened this issue Oct 19, 2024 · 3 comments · Fixed by #9731
Closed

errno.EROFS isn't available but its error string is #9733

ricknun opened this issue Oct 19, 2024 · 3 comments · Fixed by #9731
Labels
Milestone

Comments

@ricknun
Copy link

ricknun commented Oct 19, 2024

CircuitPython version

Adafruit CircuitPython 9.1.4 on 2024-09-17; Adafruit Circuit Playground Bluefruit with nRF52840

Code/REPL

...
import errno
...
try:
    with open("/textfile.txt", "a") as fp:
        ...
except OSError as e:
    print(e)  # for example prints "[Errno 30] Read-only filesystem"
    if e.errno == 30:
    ...

Behavior

The provided code works fine. The "print(e)" results in the string "[Errno 30] Read-only filesystem" and "if e.errno == 30" works as expected. But if I replace "30" with "errno.EROFS" (as described at https://docs.circuitpython.org/en/latest/docs/library/errno.html) I get "During handling of the above exception, another exception occurred" and "AttributeError: 'module' object has no attribute 'EROFS'".

Description

I would expect to have either both the string and enum (hopefully, since this is such a common error), or neither.

Additional information

See https://forums.adafruit.com/viewtopic.php?p=1032465 where this issue was discussed with Dan Halbert. Most important, I think the list of strings and list of enums in moderrno.c should agree and both include Read-Only File System. Less important (but it sure would have helped me), the documentation at https://docs.circuitpython.org/en/latest/docs/library/errno.html could be improved from "The codes available may vary per CircuitPython build" (please avoid disclaimers like this) to where to find the list that applies to my situation.

@ricknun ricknun added the bug label Oct 19, 2024
@ricknun
Copy link
Author

ricknun commented Oct 19, 2024

I just noticed Dan addressed this yesterday. See #9731.

@ricknun
Copy link
Author

ricknun commented Oct 19, 2024

But I don't think Dan's issue #9731 addresses my request above for improved documentation...

@dhalbert
Copy link
Collaborator

Less important (but it sure would have helped me), the documentation at https://docs.circuitpython.org/en/latest/docs/library/errno.html could be improved from "The codes available may vary per CircuitPython build" (please avoid disclaimers like this) to where to find the list that applies to my situation.

I have opened #9737 to cover this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants