-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
files(...).joinpath doesn't accept variable number of arguments in Python 3.10+ #257
Comments
I see support for namespace packages was added in 8e1a218 released in
In that release, the But that restriction was lifted in 6440323 (released in 5.8.0). But somehow, it seems that the |
I think I understand what's going on:
It's not obvious to me how As a short-term workaround, I suggest to use |
@FFY00 I'd like your opinion - do you think based on this report that |
I think that would be something worth exploring. That behavior seems desirable, but like you mentioned, the implementation might be a bit tricky. If we can come up with a reasonable way of doing this, it would be nice to have it, otherwise, I wouldn't worry too much. |
… have features/fixes present in this library. Fixes #257.
… have features/fixes present in this library. Fixes #257.
Here's a unit test that fails in Python 3.10 (and only in that one, AFAIK): diff --git a/importlib_resources/tests/test_files.py b/importlib_resources/tests/test_files.py
index 9e45f70..3e86ec6 100644
--- a/importlib_resources/tests/test_files.py
+++ b/importlib_resources/tests/test_files.py
@@ -34,6 +34,11 @@ class FilesTests:
def test_traversable(self):
assert isinstance(resources.files(self.data), Traversable)
+ def test_joinpath_with_multiple_args(self):
+ files = resources.files(self.data)
+ binfile = files.joinpath('subdirectory', 'binary.file')
+ self.assertTrue(binfile.is_file())
+
def test_old_parameter(self):
"""
Files used to take a 'package' parameter. Make sure anyone |
The issue is with this logic: importlib_resources/importlib_resources/future/adapters.py Lines 26 to 28 in 9f5b437
On Python 3.10, the module name for the loaders is "importlib.readers", not "importlib.resources.readers". Thanks so much for the test, which (shame on me) should have been included in the original solution. |
This happens to me when I try to access resources in a native namespace package.
Tested on:
Python 3.10.4
python:3.10-slim
,Python 3.10.5
The reason seems to be that
importlib_resources.files()
returnsMultiplexedPath
from stdlib (importlib.readers
) rather than fromimportlib_resources.readers
.To recreate:
Install any namespace package, e.g.
sphinxcontrib-htmlhelp
;Use
files
withjoinpath
to get the path of a resource.Expected output (which I get with Pythons 3.7-3.9):
Bug with Pythons 3.10:
I also tested with the code in #254 but to no aval.
The text was updated successfully, but these errors were encountered: