[issue30618] readlink for pathlib paths
Change by Girts Folkmanis : -- versions: +Python 3.9 -Python 3.8 ___ Python tracker <https://bugs.python.org/issue30618> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34534] importlib.resources does not work with packages that have no __init__.py
Girts Folkmanis added the comment: > What's the difference between "namespace packages and implicit non-namespace > packages"? To me, the semantic difference is that "namespace packages" are what is used when you have "foo.bar" and "foo.baz" come from different distributions (https://packaging.python.org/guides/packaging-namespace-packages/). They get mentioned in "setup(packages=[...])" in distribution package's setup.py. -- ___ Python tracker <https://bugs.python.org/issue34534> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34534] importlib.resources does not work with packages that have no __init__.py
New submission from Girts Folkmanis : importlib.resources does not seem to work with packages that don't have __init__.py present. Since 3.3+ generally there is no need to create empty __init__.py, as directories are automatically treated as packages even without the file present. So my expectation would be that importlib.resources would follow the same suit. Repro, where I expect that both "mod1" and "mod2" would return the files when contents() is called: $ find . . ./mod2 ./mod2/data.txt ./test.py ./mod1 ./mod1/__init__.py ./mod1/data.txt $ cat test.py import importlib.resources print('mod1:', list(importlib.resources.contents('mod1'))) print('mod2:', list(importlib.resources.contents('mod2'))) $ python3.7 test.py mod1: ['__init__.py', '__pycache__', 'data.txt'] mod2: []# < here I would expect to see files too Looking at the source of Lib/importlib/resources.py, there is the following code in contents(): [..] # Is the package a namespace package? By definition, namespace packages # cannot have resources. We could use _check_location() and catch the # exception, but that's extra work, so just inline the check. elif package.__spec__.origin is None or not package.__spec__.has_location: return () [..] This is the branch that is taken - but it's not necessarily a namespace package here, at least to my understanding. Is there a way to make the code here distinguish between namespace packages and implicit non-namespace packages here, and allow contents() (and other functions) to work? -- components: Library (Lib) messages: 324275 nosy: girtsf priority: normal severity: normal status: open title: importlib.resources does not work with packages that have no __init__.py versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue34534> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34384] os.readlink does not accept pathlib.Path on Windows
New submission from Girts Folkmanis : Documentation for os.readlink says "Changed in version 3.6: Accepts a path-like object.". This works fine on macOS, but blows up on Windows: Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> import pathlib >>> os.readlink(pathlib.Path('foo')) Traceback (most recent call last): File "", line 1, in TypeError: readlink() argument 1 must be str, not WindowsPath -- components: Library (Lib) messages: 323427 nosy: girtsf priority: normal severity: normal status: open title: os.readlink does not accept pathlib.Path on Windows type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue34384> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30618] readlink for pathlib paths
Change by girts : -- keywords: +patch pull_requests: +7819 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue30618> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30618] readlink for pathlib paths
girts added the comment: Just ran into the same thing. I would be interested in adding support for a "readlink" call if a pull request on this would be welcome. -- nosy: +girts ___ Python tracker <https://bugs.python.org/issue30618> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com