-
-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Description
Resource
is currently defined as:
Resource = Union[str, os.PathLike]
os.PathLike
is:
An abstract base class for objects representing a file system path, e.g. pathlib.PurePath.
Resources are not file system entities and os.PathLike
is therefore inappropriate. In addition, os.fspath
is not used to convert Resource
s to strings, so functions which manipulate paths are unsafe:
In [1]: !python -m pip show importlib-resources | rg Version
Version: 5.3.0
In [2]: import importlib_resources
In [3]: class Foo:
...: def __fspath__(self):
...: return "__init__.py"
...:
In [4]: importlib_resources.open_text("asyncio", Foo())
[...]
FileNotFoundError: [Errno 2] No such file or directory: '/nix/store/qx995zl14gqgx0ly0hwx3cy0fcz27ich-python3-3.9.6/lib/python3.9/asyncio/<__main__.Foo object at 0x11172d550>'
Metadata
Metadata
Assignees
Labels
No labels