This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author indygreg
Recipients barry, indygreg
Date 2019-02-26.21:05:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The implementation of the ResourceReader API for the FileLoader class in importlib/ 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 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')

The behavior has been present since the functionality was added (
Date User Action Args
2019-02-26 21:05:00indygregsetrecipients: + indygreg, barry
2019-02-26 21:05:00indygregsetmessageid: <>
2019-02-26 21:05:00indygreglinkissue36128 messages
2019-02-26 21:05:00indygregcreate