-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-39791 native hooks for importlib.resources.files #20576
Conversation
Still to do in another PR, I'd like to replace the zipimporter Resource Reader with a TraversableAdapter over ZipImporter.files, but I'm deferring that for now to get these changes in before the next 3.9 beta. |
I've figured out why the tests are failing. It's the importlib_metadata tests that are failing, and it's because the fixtures for setting up the This change alters the way that So there are really several issues here:
(1) was intentional knowing it was somewhat inefficient but creates a more uniform interaction with resources. Regardless, there's more work to be done here. |
As I thought about it more, I realized that by updating |
This is closer now. Just two failures:
|
I may have made a grave miscalculation - that a I believe this is why |
…ule name context.
I believe this is ready to go. If Brett or Barry have time to review today or tomorrow, that would be great. Otherwise, I'll submit and continue to iterate. In particular, the docs will need to be updated on the "integration", now that |
return self.path | ||
|
||
|
||
class ZipReader(FileReader): |
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.
I'm probably going to decouple FileReader from ZipReader. The only shared functionality is the one-line files
method.
…face for extension via get_resource_reader.
Thanks @jaraco for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
* Provide native .files support on SourceFileLoader. * Add native importlib.resources.files() support to zipimporter. Remove fallback support. * make regen-all * 📜🤖 Added by blurb_it. * Move 'files' into the ResourceReader so it can carry the relevant module name context. * Create 'importlib.readers' module and add FileReader to it. * Add zip reader and rely on it for a TraversableResources object on zipimporter. * Remove TraversableAdapter, no longer needed. * Update blurb. * Replace backslashes with forward slashes. * Incorporate changes from importlib_metadata 2.0, finalizing the interface for extension via get_resource_reader. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> (cherry picked from commit 843c277) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
GH-20703 is a backport of this pull request to the 3.9 branch. |
* Provide native .files support on SourceFileLoader. * Add native importlib.resources.files() support to zipimporter. Remove fallback support. * make regen-all * 📜🤖 Added by blurb_it. * Move 'files' into the ResourceReader so it can carry the relevant module name context. * Create 'importlib.readers' module and add FileReader to it. * Add zip reader and rely on it for a TraversableResources object on zipimporter. * Remove TraversableAdapter, no longer needed. * Update blurb. * Replace backslashes with forward slashes. * Incorporate changes from importlib_metadata 2.0, finalizing the interface for extension via get_resource_reader. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> (cherry picked from commit 843c277) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
…ythonGH-20576)" This reverts commit 9cf1be4 due to https://bugs.python.org/issue40924.
…es.files (GH-20576)" (#20760) This reverts commit 9cf1be4 due to https://bugs.python.org/issue40924.
* Provide native .files support on SourceFileLoader. * Add native importlib.resources.files() support to zipimporter. Remove fallback support. * make regen-all * 📜🤖 Added by blurb_it. * Move 'files' into the ResourceReader so it can carry the relevant module name context. * Create 'importlib.readers' module and add FileReader to it. * Add zip reader and rely on it for a TraversableResources object on zipimporter. * Remove TraversableAdapter, no longer needed. * Update blurb. * Replace backslashes with forward slashes. * Incorporate changes from importlib_metadata 2.0, finalizing the interface for extension via get_resource_reader. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Integrate native
.files()
support for SourceFileLoader and ZipImporter. Remove the 'fallback' behavior and rely entirely onloader.files()
for all resources.https://bugs.python.org/issue39791