You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PackagePath cannot be created on your platform (Windows) #51
When I selected pathlib.PosixPath, I had assumed that like the posixpath module, it was cross-platform, providing a uniform interface across platforms. I can't recall if I did this to support zipfiles or just as an arbitrary choice. Let's experiment to see if using pathlib.Path as the base class for PackagePath is sufficient to get tests to pass on Windows.
diff --git a/importlib_metadata/api.py b/importlib_metadata/api.py
index cddc03f..1eed683 100644
--- a/importlib_metadata/api.py
+++ b/importlib_metadata/api.py
@@ -97,7 +97,7 @@ class EntryPoint(collections.namedtuple('EntryPointBase', 'name value group')):
return iter((self.name, self))
-class PackagePath(pathlib.PosixPath):
+class PackagePath(pathlib.Path):
"""A reference to a path in a package"""
def read_text(self, encoding='utf-8'):
But even on Unix, the tests fail.
======================================================================
ERROR: test_file_hash_repr (importlib_metadata.tests.test_api.APITests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/jaraco/code/public/importlib_metadata/importlib_metadata/tests/test_api.py", line 92, in test_file_hash_repr
p for p in importlib_metadata.files('wheel')
File "/Users/jaraco/code/public/importlib_metadata/importlib_metadata/tests/test_api.py", line 92, in <listcomp>
p for p in importlib_metadata.files('wheel')
File "/Users/jaraco/code/public/importlib_metadata/importlib_metadata/api.py", line 213, in make_file
result = PackagePath(name)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py", line 994, in __new__
self = cls._from_parts(args, init=False)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py", line 649, in _from_parts
drv, root, parts = self._parse_args(args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py", line 642, in _parse_args
return cls._flavour.parse_parts(parts)
AttributeError: type object 'PackagePath' has no attribute '_flavour'
Activity
jaraco commentedon Oct 22, 2020
In GitLab by @jaraco on Feb 24, 2019, 15:50
When I selected
pathlib.PosixPath, I had assumed that like theposixpathmodule, it was cross-platform, providing a uniform interface across platforms. I can't recall if I did this to support zipfiles or just as an arbitrary choice. Let's experiment to see if usingpathlib.Pathas the base class forPackagePathis sufficient to get tests to pass on Windows.jaraco commentedon Oct 22, 2020
In GitLab by @jaraco on Feb 24, 2019, 16:48
I tried making the switch
But even on Unix, the tests fail.
jaraco commentedon Oct 22, 2020
In GitLab by @jaraco on Feb 24, 2019, 20:22
It seems that even this simple Python fails similarly:
jaraco commentedon Oct 22, 2020
In GitLab by @jaraco on Feb 24, 2019, 20:27
Okay, it's not possible to subclass Path or PurePath.
jaraco commentedon Oct 22, 2020
In GitLab by @jaraco on Feb 25, 2019, 03:19
mentioned in commit a15b5db
jaraco commentedon Oct 22, 2020
In GitLab by @jaraco on Feb 25, 2019, 03:19
mentioned in merge request !49
jaraco commentedon Oct 22, 2020
In GitLab by @jaraco on Feb 25, 2019, 03:20
closed via commit a15b5db
jaraco commentedon Oct 22, 2020
In GitLab by @jaraco on Feb 25, 2019, 03:20
closed via merge request !49