-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
zipimport raises NameError: name '_boostrap_external' is not defined #83214
Comments
I think there's a "t" missing: Lib/zipimport.py |
Good catch! Would you like to submit a pull request to fix it? Ideally such a PR should also include a test to exercise this code. |
Is it possible to scan stdlib to find similar bugs? |
A possible test case to trigger this code path based on testUncheckedHashBasedPyc would be as below. check_hash_based_pycs can be patched to be "always" so that the hash is validated using _bootstrap_external._validate_hash_pyc. The difference between "state = old" for pyc and "state = new" in py would ensure the hashes are different to raise ImportError expected and the test picks up state = new as the updated source code. Without fixing the typo trying to make hash validation would throw NameError. @unittest.mock.patch('_imp.check_hash_based_pycs', 'always') |
Also since the fix involves modifying zipimport.py it would also require running "make regen-importlib && make -s" for changes to ensure the updated regen code is used. |
Ma Lin, Running pylint/flake8 could possibly detect it but needs to be manually checked. bpo-36948 was a similar report I filed in the past using flake8 regarding NameError. pylint - Lib/zipimport.py:611:20: E0602: Undefined variable '_boostrap_external' (undefined-variable) |
Wince you has virtually written a patch, do you mind to create a PR Karthikeyan? |
Sure Serhiy, I will create one. |
Thank you, Mihail and Karthikeyan! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: