cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-121342: Fixed `pkgutil.iter_zipimport_modules` on an invalidated cache (#121342)

Open beachmachine opened this issue 1 year ago • 2 comments

It is no longer safe to directly access zipimport._zip_directory_cache since #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.

  • Issue: gh-121342

beachmachine avatar Jul 13 '24 14:07 beachmachine

Only a few formatting nitpicks. Failing CI is caused by pkgutil.iter_zipimport_modules being undocumented. Ideally, you should document it with this PR.

Added documentation to that, but now the CI complaints that py:func reference target not found: pkgutil.iter_zipimport_modules, which confuses me as it is clearly there. :thinking:

beachmachine avatar Jul 14 '24 10:07 beachmachine

Only a few formatting nitpicks. Failing CI is caused by pkgutil.iter_zipimport_modules being undocumented. Ideally, you should document it with this PR.

Added documentation to that, but now the CI complaints that py:func reference target not found: pkgutil.iter_zipimport_modules, which confuses me as it is clearly there. 🤔

Ah, it wasn't clear to me that the public documentation and the docstrings are a separate thing.

As pkgutil.iter_zipimport_modules isn't supposed to be consumed directly by anything other than pkgutils itself, and is registered 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. However, I've added a docstring for the function.

beachmachine avatar Jul 14 '24 11:07 beachmachine