-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-142029: Raise ModuleNotFoundError instead of crashing on nonexsistent module name given to create_builtin()
#142054
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
gh-142029: Raise ModuleNotFoundError instead of crashing on nonexsistent module name given to create_builtin()
#142054
Conversation
|
On further inspection, |
No longer relevant for the improved implementation. Thanks to @itamaro. |
|
Tests seem to be failing on Android/iOS because pickled Unfortunately it's not reproducible on my Linux computer (hence the Linux tests passing fine). Not sure if it's trying to compare the new |
vstinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer raising an exception as done in #142033 instead of returning None.
Sounds good. Would a |
None instead of crashing on nonexsistent module name given to create_builtin()ModuleNotFoundError instead of crashing on nonexsistent module name given to create_builtin()
|
#142033 has been merged instead. |
|
@vstinner #142033 only fixes one of the two issues included in #142029. The first issue mentioned in that bug report is still unfixed, i.e. the following will crash on >>> import _imp
>>> class A: pass
...
>>> a = A()
>>> a.name = "123"
>>> _imp.create_builtin(a)But this would raise a |
vstinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. But there are now conflicts in Lib/test/test_import/init.py: can you try to solve them? (git merge main)
|
Oh sorry, I didn't see that the issue had two sub-issues. |
Yep, just done so. |
Co-authored-by: Victor Stinner <vstinner@python.org>
|
Strange, pickle tests failed on iOS and Android: Example of failure: |
|
This error came up in #103247, and I think @freakboy3742 dealt with a more recent instance, but I can't find it now. |
Thanks! |
|
Okay, manged to reproduce the error on Linux with |
|
Merged, thanks for the fix. |
|
|
Unfortunately I'm unsure why this buildbot is failing - it's only happening on ARM Raspbian. It's not having issues importing anything (which is what this PR changes). Plus, the failure is only on this one specific test which seems totally unrelated. However, the test only seems to be failing after this commit, and it's happening now on other commits (27a2e49). |
…onexsistent module name given to `create_builtin()` (python#142054) Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
The failure seems to be unrelated. |
Py_NewRef(Py_None)was returned in this case; so, theoretically, this should be re-introducing behaviour that was previously broken by that commit.create_builtinwith invalid object #142029