Message 336712 - Python tracker (original) (raw)

Message336712

Author indygreg
Recipients barry, indygreg
Date 2019-02-26.21:05:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id 1551215100.55.0.236644911032.issue36128@roundup.psfhosted.org
In-reply-to
Content
The implementation of the ResourceReader API for the FileLoader class in importlib/_bootstrap_external.py is inconsistent with regards to handling of path separators. Specifically, "is_resource()" returns False if "resource" has a path separator. But "open_resource()" will happily open resources containing a path separator. I would think the two would agree about whether a path with separators is a resource or not. The documentation at https://docs.python.org/3.7/library/importlib.html#importlib.abc.ResourceReader implies that resources in subdirectories should not be allowed. One can easily demonstrate this behavior oddity with Mercurial: (Pdb) p sys.modules['mercurial'].__spec__.loader.get_resource_reader('mercurial').open_resource('help/config.txt') <_io.FileIO name='/home/gps/src/hg/mercurial/help/config.txt' mode='rb' closefd=True> (Pdb) p sys.modules['mercurial'].__spec__.loader.get_resource_reader('mercurial').is_resource('help/config.txt') False The behavior has been present since the functionality was added (https://github.com/python/cpython/pull/5168).
History
Date User Action Args
2019-02-26 21:05:00 indygreg set recipients: + indygreg, barry
2019-02-26 21:05:00 indygreg set messageid: 1551215100.55.0.236644911032.issue36128@roundup.psfhosted.org
2019-02-26 21:05:00 indygreg link issue36128 messages
2019-02-26 21:05:00 indygreg create