Skip to content
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

Switch on importlib.resources #936

Closed
wants to merge 2 commits into from

Conversation

shadchin
Copy link
Contributor

@shadchin shadchin commented May 4, 2024

Description

What's wrong with__file__? The assumption that you have files and subdirectories available is not correct. This approach doesn't work if executing code which is packed in a zip or a wheel, and it may be entirely out of the user's control whether or not your package gets extracted to a filesystem at all.

Types of change

Switch on importlib.resources.files (Added in version Python 3.9.)

Checklist

  • I confirm that I have the right to submit this contribution under the project's MIT license.
  • I ran the tests, and all new and existing tests passed.
  • My changes don't require a change to the documentation, or if they do, I've added all required information.

Sorry, something went wrong.

shadchin and others added 2 commits May 4, 2024 09:06

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
What's wrong with`__file__`? The assumption that you have files and subdirectories available is not correct. This approach doesn't work if executing code which is packed in a zip or a wheel, and it may be entirely out of the user's control whether or not your package gets extracted to a filesystem at all.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@honnibal
Copy link
Member

As a general rule we're not claiming to support zip-safe operation, and there may be other places in the code where we're not zip safe. So I'm not inclined to accept a piecemeal change; if we want zip safety it should all be done at once.

This isn't something I'd ask a contributor to do as I haven't thought through the trade-offs properly, and I may end up having to reject the PR. Nevertheless, thanks for your attention and the submission of what seemed like a small fix!

@honnibal honnibal closed this Jul 18, 2024
@shadchin shadchin deleted the shadchin-patch-1 branch July 19, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants