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
importlib.invalidate_caches() doesn't clear all caches #77350
Comments
See python/mypy#4811. To summarize, importlib.invalidate_caches() doesn't clear the negative cache in sys.path_importer_cache. Could be related to https://bugs.python.org/issue30891? |
Correct because as documented it calls invalidate_caches() on meta-path finders and the one that handles sys.path calls invalidate_caches() on the finders found in sys.path_importer_cache() (as documented by https://docs.python.org/3/library/importlib.html#importlib.machinery.PathFinder.invalidate_caches). Since None isn't a finder it doesn't do anything there as there is no method to call. So the "full of lies" comment by the OP on the mypy repo is over-the-top/incorrect. Now tweaking cpython/Lib/importlib/_bootstrap_external.py Lines 1180 to 1186 in 5219952
|
I agree that we can't change 3.6 at this late stage, but the change is borderline enough on the "new feature"/"bug fix" scale that I think it's worth asking Ned if he's comfortable with us changing it for 3.7.0b4. Ned: the change we'd like to make is to update PathFinder.invalidate_caches to delete all entries in sys.path_importer_cache that have a value of None. |
The current behavior is causing problems for at least some use cases so it does seems to be closer to a bug than a feature. If there is agreement that it is desirable to make the change, I think it's better to do it now in 3.7 than later. |
SGTM. On Fri, Mar 30, 2018, 06:41 Ned Deily <report@bugs.python.org> wrote:
|
OK, I will update importlib.machinery.PathFinder.invalidate_caches() to also drop None from sys.path_importer_cache (objects that are not None and do not define invalidate_caches() will be left alone just like they are today). I should hopefully be able to get to this before b4. |
All done in 3.7 and master. |
None
from sys.path_importer_cache when invalidating caches #6402None
from sys.path_importer_cache when invalidating caches (GH-6402) #6403Note: 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: