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

Throw error for unsupported dunder methods #8602

Merged
merged 4 commits into from Nov 18, 2022
Merged

Throw error for unsupported dunder methods #8602

merged 4 commits into from Nov 18, 2022

Conversation

apmasell
Copy link
Contributor

Make jitclass throw an error rather than ignore unhandled __X__ methods.

Make jitclass throw an error rather than ignore unhandled `__X__` methods.
Copy link
Contributor

@stuartarchibald stuartarchibald left a comment

Choose a reason for hiding this comment

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

Thanks for the patch. One minor comment to resolve else looks good.

if (
name.startswith("__")
and name.endswith("__")
and name not in supported_dunders
):
continue
raise TypeError("Method {0} is not supported".format(name))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest adding a unit test that checks this error message is raised as expected to numba.tests.test_jitclasses.

@stuartarchibald stuartarchibald added the Effort - short Short size effort needed label Nov 16, 2022
@stuartarchibald stuartarchibald self-assigned this Nov 16, 2022
@stuartarchibald stuartarchibald added this to the Numba 0.57 RC milestone Nov 16, 2022
@stuartarchibald stuartarchibald added 4 - Waiting on author Waiting for author to respond to review and removed 3 - Ready for Review labels Nov 16, 2022
Ensure forbidden dunder methods are not created.
@apmasell apmasell added 3 - Ready for Review and removed 4 - Waiting on author Waiting for author to respond to review labels Nov 16, 2022
Copy link
Contributor

@stuartarchibald stuartarchibald left a comment

Choose a reason for hiding this comment

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

@apmasell many thanks for adding the test. Couple of minor things to resolve else looks good.

numba/experimental/jitclass/boxing.py Outdated Show resolved Hide resolved
numba/tests/test_jitclasses.py Outdated Show resolved Hide resolved
@stuartarchibald stuartarchibald added 4 - Waiting on author Waiting for author to respond to review and removed 3 - Ready for Review labels Nov 17, 2022
apmasell and others added 2 commits November 17, 2022 15:11
Co-authored-by: stuartarchibald <stuartarchibald@users.noreply.github.com>
Co-authored-by: stuartarchibald <stuartarchibald@users.noreply.github.com>
Copy link
Contributor

@stuartarchibald stuartarchibald left a comment

Choose a reason for hiding this comment

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

Thanks for the patch and fixes!

@stuartarchibald stuartarchibald added 5 - Ready to merge Review and testing done, is ready to merge and removed 4 - Waiting on author Waiting for author to respond to review labels Nov 18, 2022
@sklam sklam merged commit 3bee7be into numba:main Nov 18, 2022
@apmasell apmasell deleted the jitclass_dunder branch November 18, 2022 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to merge Review and testing done, is ready to merge Effort - short Short size effort needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants