-
-
Notifications
You must be signed in to change notification settings - Fork 32k
pkgutil direct use of zipimport._zip_directory_cache is no longer safe #121342
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
Labels
type-bug
An unexpected behavior, bug, or error
Comments
beachmachine
added a commit
to beachmachine/cpython
that referenced
this issue
Jul 13, 2024
…ated cache (python#121342) It is no longer safe to directly access `zipimport._zip_directory_cache` since python#103208. It is not guaranteed that the cache is acutally filled. This changed fixes this by using the internal method `_get_files` instead, which may not be the best solution, but fixes the issue.
beachmachine
added a commit
to beachmachine/cpython
that referenced
this issue
Jul 13, 2024
…ated cache (python#121342) It is no longer safe to directly access `zipimport._zip_directory_cache` since python#103208. It is not guaranteed that the cache is acutally filled. This changed fixes this by using the internal method `_get_files` instead, which may not be the best solution, but fixes the issue.
beachmachine
added a commit
to beachmachine/cpython
that referenced
this issue
Jul 13, 2024
…ated cache (python#121342) It is no longer safe to directly access `zipimport._zip_directory_cache` since python#103208. It is not guaranteed that the cache is acutally filled. This changed fixes this by using the internal method `_get_files` instead, which may not be the best solution, but fixes the issue.
beachmachine
added a commit
to beachmachine/cpython
that referenced
this issue
Jul 13, 2024
…ated cache (python#121342) It is no longer safe to directly access `zipimport._zip_directory_cache` since python#103208. It is not guaranteed that the cache is acutally filled. This changed fixes this by using the internal method `_get_files` instead, which may not be the best solution, but fixes the issue.
beachmachine
added a commit
to beachmachine/cpython
that referenced
this issue
Jul 14, 2024
…ated cache (python#121342) It is no longer safe to directly access `zipimport._zip_directory_cache` since python#103208. It is not guaranteed that the cache is acutally filled. This changed fixes this by using the internal method `_get_files` instead, which may not be the best solution, but fixes the issue.
beachmachine
added a commit
to beachmachine/cpython
that referenced
this issue
Jul 14, 2024
As `pkgutil.iter_zipimport_modules` isn't supposed to be consumed directly by anything other than `pkgutils` itself, and is registered via as an importer module for `zipimporter`, I've decided to not include it in the public documentation. Thus, the `:func:` reference of `pkgutil.iter_zipimport_modules` in the news file is removed now.
beachmachine
added a commit
to beachmachine/cpython
that referenced
this issue
Jul 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
Bug description:
pkgutil directly uses zipimport._zip_directory_cache, in this block:
since #103208 , this is no longer safe, because that made zipimport no longer always refresh the cache on invalidation. I think that if the cache has been invalidated but not accessed 'normally' since then, this direct access attempt can cause a crash as it doesn't trigger a refresh:
I observed this in the test suite for dask-distributed - see dask/distributed#8708 - but it seems like a general issue, and @desmondcheongzx asked me to file an issue, so here it is. That test suite hits it in a test that runs async and creates archives under the same name repeatedly, but there are probably other ways to hit this, I guess.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
pkgutil.iter_zipimport_modules
on an invalidated cache (#121342) #121705The text was updated successfully, but these errors were encountered: