8000 Human readable OSError messages for low flash devices by godlygeek · Pull Request #891 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Human readable OSError messages for low flash devices #891

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 G 10000 itHub”, 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

Merged
merged 4 commits into from
Jun 5, 2018

Conversation

godlygeek
Copy link

#837 implemented human readable OSError messages, but excluded low-flash devices (ones with BOARD_FLASH_SIZE <= 192000).

This PR improves the situation on those devices:

Adafruit CircuitPython 3.0.0-beta.0-32-gd6ff451-dirty on 2018-06-01; Adafruit Gemma M0 with samd21e18
>>> for i in range(32): print(OSError(i))
...
[Errno 0]
[Errno 1] EPERM
[Errno 2] ENOENT
[Errno 3]
[Errno 4]
[Errno 5] EIO
[Errno 6]
[Errno 7]
[Errno 8]
[Errno 9]
[Errno 10]
[Errno 11] EAGAIN
[Errno 12] ENOMEM
[Errno 13] EACCES
[Errno 14]
[Errno 15]
[Errno 16]
[Errno 17] EEXIST
[Errno 18]
[Errno 19] ENODEV
[Errno 20]
[Errno 21] EISDIR
[Errno 22] EINVAL
[Errno 23]
[Errno 24]
[Errno 25]
[Errno 26]
[Errno 27]
[Errno 28]
[Errno 29]
[Errno 30]
[Errno 31]

On devices with low flash, we still won't create the uerrno module. Instead, we'll create a utility method that knows how to map each of the errno's that we can raise to its name. In order to save flash, we also prune the list of errno's that the utility method must know about down to just the subset that can be raised on atmel-samd.

@godlygeek godlygeek force-pushed the low_flash_errno_fixes branch from b97cfdd to 0f4280a Compare June 1, 2018 22:50
godlygeek added 3 commits June 1, 2018 19:03
We can provide a basic version of mp_errno_to_str even if the uerrno
module won't be provided.  Rather than looking errno names up in the
uerrno module's globals dict, we'll just rely on a simple mapping in the
function itself.
The uerrno module was written to allow boards to customize the list of
errnos they can raise.  Start by copying the default list.
Remove errnos that are only raised by modules that aren't linked into
the atmel-samd port.
@godlygeek godlygeek force-pushed the low_flash_errno_fixes branch from 0f4280a to 22f4438 Compare June 1, 2018 23:04
@tannewt tannewt self-requested a review June 5, 2018 00:20
@tannewt tannewt added this to the 3.0 milestone Jun 5, 2018
Copy link
Member
@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! This looks great. Nice and clean. Thank you!

@tannewt tannewt merged commit 0c7c082 into adafruit:master Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0