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

Fix crash when bad MPY file #155

Merged
merged 2 commits into from
Dec 9, 2022
Merged

Conversation

Neradoc
Copy link
Contributor

@Neradoc Neradoc commented Oct 31, 2022

This avoids crashing into an exception when an mpy file is not found to be valid. That happens when it doesn't start with the expected headers (M3 or C5). This can happen if the file is corrupted, empty, or for example a py file is renamed mpy.
The version is set to a special value, and a warning is emitted during update similarly to when the format is valid but does not match the version of Circuitpython.
I didn't add a unit test yet.

fixes #146

Copy link
Member

@tekktrik tekktrik left a comment

Choose a reason for hiding this comment

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

Looked this over and it all seems good, I assume we'd wait for the unit test before approving/merging.

@dhalbert dhalbert merged commit 55b0139 into adafruit:main Dec 9, 2022
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.

UnboundLocalError: local variable 'loc' referenced before assignment
3 participants