-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
New files()
api from importlib_resources.
#83972
Comments
In the importlib_resources backport... in particular in issue 58 and merge request 76, the backport now has a new feature, a "files()" function. Let's incorporate that functionality into importlib.resources. |
The latest release, 1.3.0, includes extensibility support and has been merged with the cpython branch of the importlib_resources project. I believe that code is now synced with this project and ready to be applied here. I'm hoping benthayer can apply the changes and submit the pr. |
I've merged PR 19722. Some follow up actions I'd like to do:
|
The 'fancy' file name breaks on latin-1 character set. aixtools@gcc119:[/home/aixtools/python/py39-3.9] a4fa9a95153a3800dea60b3029b2dcaf8a4f6acb Lib/test/test_importlib/test_main.py <
diff --git a/Lib/test/test_importlib/test_main.py b/Lib/test/test_importlib/test_main.py
index 42a7999..7b18c3d 100644
--- a/Lib/test/test_importlib/test_main.py
+++ b/Lib/test/test_importlib/test_main.py
@@ -246,3 +246,19 @@ class TestEntryPoints(unittest.TestCase):
"""
with self.assertRaises(Exception):
json.dumps(self.ep)
+
+ def test_module(self):
+ assert self.ep.module == 'value'
+
+ def test_attr(self):
+ assert self.ep.attr is None
+
+
+class FileSystem(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
+ def test_unicode_dir_on_sys_path(self):
+ """
+ Ensure a Unicode subdirectory of a directory on sys.path
+ does not crash.
+ """
+ fixtures.build_files({'☃': {}}, prefix=self.site_dir)
+ list(distributions()) AIX bots fail with: Captured traceback Traceback (most recent call last):
File "/home/shager/cpython-buildarea/3.9.edelsohn-aix-ppc64/build/Lib/test/test_importlib/test_main.py", line 263, in test_unicode_dir_on_sys_path
fixtures.build_files({'\u2603': {}}, prefix=self.site_dir)
File "/home/shager/cpython-buildarea/3.9.edelsohn-aix-ppc64/build/Lib/test/test_importlib/fixtures.py", line 202, in build_files
full_name.mkdir()
File "/home/shager/cpython-buildarea/3.9.edelsohn-aix-ppc64/build/Lib/pathlib.py", line 1309, in mkdir
self._accessor.mkdir(self, mode)
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2603' in position 17: ordinal not in range(256) Test report Failed tests:
|
Thanks for the report Michael. I'm trying to figure out the best way to address the issue. That test is shared with importlib_metadata, so needs to run without CPython's test suite fixtures, such as the ones that generate non-ascii filenames. I'm tempted to just attempt to create the fixture and skip if the fixture fails. An alternate approach might be to attempt to load CPython's fixture, skip if that value is None, and fallback to the snowman otherwise. |
See #64880 for a proposed fix. I've scheduled the build bots to run the patch. Will build bots prove the fix? If not, can you test the patch in the same environment where it was discovered? |
Note that the most recent commits have introduced a critical regression in importlib.resources.path() that breaks the certifi package from PyPI and presumably other users of path(). See bpo-40924. |
This issue was implemented, just not as fully as I'd have hoped. Still lacking is native support for .files on the built-in package providers and removing the legacy APIs or at least configuring them to rely on the files API, but as far as supplying the files API, this work is done. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: