Title: ResourceReader API can't be implemented for zipimporter · Issue #49 · python/importlib_resources · GitHub
Open Graph Title: ResourceReader API can't be implemented for zipimporter · Issue #49 · python/importlib_resources
X Title: ResourceReader API can't be implemented for zipimporter · Issue #49 · python/importlib_resources
Description: In GitLab by @warsaw on Jan 2, 2018, 13:25 The ResourceReader APIs only take a single resource argument, but this is incompatible with the current implementation of zipimporter. The problem is that, unlike with file-based modules, all mo...
Open Graph Description: In GitLab by @warsaw on Jan 2, 2018, 13:25 The ResourceReader APIs only take a single resource argument, but this is incompatible with the current implementation of zipimporter. The problem is that...
X Description: In GitLab by @warsaw on Jan 2, 2018, 13:25 The ResourceReader APIs only take a single resource argument, but this is incompatible with the current implementation of zipimporter. The problem is that...
Opengraph URL: https://github.com/python/importlib_resources/issues/49
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ResourceReader API can't be implemented for zipimporter","articleBody":"In GitLab by @warsaw on Jan 2, 2018, 13:25\n\nThe `ResourceReader` APIs only take a single `resource` argument, but this is incompatible with the current implementation of zipimporter. The problem is that, unlike with file-based modules, all modules imported from a zip file share the same loader:\n\n```python\n\u003e\u003e\u003e import test.test_importlib.zipdata02\n\u003e\u003e\u003e import sys, os\n\u003e\u003e\u003e sys.path.insert(0, os.path.join(os.path.dirname(test.test_importlib.zipdata02.__file__), 'ziptestdata.zip'))\n\u003e\u003e\u003e import ziptestdata.two\n\u003e\u003e\u003e import ziptestdata.one\n\u003e\u003e\u003e ziptestdata.one.__spec__.loader == ziptestdata.two.__spec__.loader\nTrue\n```\n\nSo let's say you have a resource called `myresource.txt` in `ziptestdata.two` and `ziptestdata.one`. The implementation of [ResourceReader.open_resource()](https://github.com/python/cpython/blob/master/Lib/importlib/abc.py#L350) on the zipimporter's loader can't possibly know which `myresource.txt` file is being requested.\n\n@brettcannon mentioned PEP 302's design decision not to require a unique loader instance per module, and wanted to move away from that, but I think we're stuck with requiring a `package` argument to the `ResourceReader`. The only other option would be to change zipimporter to provide a unique loader instance per module, but that seems like a backward compatibility break. Besides, if other 3rd party loaders follow the same implementation of a shared loader, they won't be able to implement `ResourceReader` either.","author":{"url":"https://github.com/jaraco","@type":"Person","name":"jaraco"},"datePublished":"2020-10-21T21:55:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/49/importlib_resources/issues/49"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:98aced3e-70cb-2602-0b6f-b9688d91fc19 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE6E:28D644:1966AD6:21C2C46:6A52C154 |
| html-safe-nonce | dd5c1ab149bfa60675a609e60610430c9bef9c153bc6d4c4aaf2e8a07590cdc4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTZFOjI4RDY0NDoxOTY2QUQ2OjIxQzJDNDY6NkE1MkMxNTQiLCJ2aXNpdG9yX2lkIjoiMjA4MTAzNjUxOTk4NTAzNzY1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ec6865c5415c80bdb9f46d90ca16d5c8a02e79251f1b40cbfbdaccdec9b85490 |
| hovercard-subject-tag | issue:726890059 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/importlib_resources/49/issue_layout |
| twitter:image | https://opengraph.githubassets.com/907eeccc7d754c175aa959b3bfc590f099b1d25ed98c1c0507d77af1ebfe548f/python/importlib_resources/issues/49 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/907eeccc7d754c175aa959b3bfc590f099b1d25ed98c1c0507d77af1ebfe548f/python/importlib_resources/issues/49 |
| og:image:alt | In GitLab by @warsaw on Jan 2, 2018, 13:25 The ResourceReader APIs only take a single resource argument, but this is incompatible with the current implementation of zipimporter. The problem is that... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jaraco |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/importlib_resources git https://github.com/python/importlib_resources.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 306147182 |
| octolytics-dimension-repository_nwo | python/importlib_resources |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 306147182 |
| octolytics-dimension-repository_network_root_nwo | python/importlib_resources |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width