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

modbuiltins: Catch most exceptions during dir() #6539

Merged
merged 1 commit into from
Jul 1, 2022

Conversation

jepler
Copy link
Member

@jepler jepler commented Jun 30, 2022

This helps with Python-compatibility (see issue #4171) but doesn't completely resolve it.

Now, dir() still computes any properties of the underlying object, HOWEVER, if the property raises an exception this exception is captured.

This ability to capture exceptions always existed in mp_load_method_protected, we just need to turn it on via the catch_all_exc boolean parameter.

This helps with Python-compatibility (see issue adafruit#4171) but doesn't
completely resolve it.

Now, `dir()` still computes any properties of the underlying object,
HOWEVER, if the property raises an exception this expression is
captured.

This ability to capture exceptions always existed in
`mp_load_method_protected`, we just need to turn it on via the
`catch_all_exc` boolean parameter.
Copy link
Member

@gamblor21 gamblor21 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Good catch that the raise was being called causing the exception.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

This is a good workaround to make dir() more usable. Thanks!

@dhalbert dhalbert merged commit 819b5d1 into adafruit:main Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants