gh-121342: Fixed `pkgutil.iter_zipimport_modules` on an invalidated cache (#121342)
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
Only a few formatting nitpicks. Failing CI is caused by
pkgutil.iter_zipimport_modulesbeing 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:
Only a few formatting nitpicks. Failing CI is caused by
pkgutil.iter_zipimport_modulesbeing 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.