-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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-99508: fix TypeError
in Lib/importlib/_bootstrap_external.py
#99635
Conversation
I obviously can't answer 1. but with regard to 2. As far as I can tell in order to hit this line the test would need to have a subclass of I'm not sure such a test would make sense, but I guess that's a separate discussion? (I was writing my own |
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.
This looks correct to me. I don't think we need a test, even though it'd be nice.
Requesting a review from @benjaminp as the author of #4575.
A test would be good it have. (It seems you can get into this state by having a hash-based pyc where the source exists but not the bytecode cache?) |
I don't think so, the only line in the method that changes cpython/Lib/importlib/_bootstrap_external.py Lines 1099 to 1110 in 2781ec9
|
I think the test case is way too complex for such an obvious change:
if (_imp.check_hash_based_pycs != 'never' and
(check_source or
_imp.check_hash_based_pycs == 'always')): I don't really think that such brittle unit tests will be worth it 😞 |
I agree the test case is too complicated but it's actually worse. If this condition is skipped the function returns early in the else block of the try/except so you still can't reach this line. cpython/Lib/importlib/_bootstrap_external.py Lines 1133 to 1138 in 2781ec9
The only way for |
This code is clearly not covered and not used (otherwise this bug would be noticed):
CC @FFY00