summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2018-03-27 16:59:38 (GMT)
committerGitHub <noreply@github.com>2018-03-27 16:59:38 (GMT)
commit30e507dff465a31901d87df791a2bac40dc88530 (patch)
treeae5ed579a2bcc2cd83ace768d78636221f0d0b8e /Lib/importlib
parentda1734c58d2f97387ccc9676074717d38b044128 (diff)
downloadcpython-30e507dff465a31901d87df791a2bac40dc88530.zip
cpython-30e507dff465a31901d87df791a2bac40dc88530.tar.gz
cpython-30e507dff465a31901d87df791a2bac40dc88530.tar.bz2
bpo-33151: Handle submodule resources (GH-6268)
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/resources.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/importlib/resources.py b/Lib/importlib/resources.py
index c4f6bbd..e565427 100644
--- a/Lib/importlib/resources.py
+++ b/Lib/importlib/resources.py
@@ -267,11 +267,12 @@ class _ZipImportResourceReader(resources_abc.ResourceReader):
self.fullname = fullname
def open_resource(self, resource):
- path = f'{self.fullname}/{resource}'
+ fullname_as_path = self.fullname.replace('.', '/')
+ path = f'{fullname_as_path}/{resource}'
try:
return BytesIO(self.zipimporter.get_data(path))
except OSError:
- raise FileNotFoundError
+ raise FileNotFoundError(path)
def resource_path(self, resource):
# All resources are in the zip file, so there is no path to the file.
@@ -282,7 +283,8 @@ class _ZipImportResourceReader(resources_abc.ResourceReader):
def is_resource(self, name):
# Maybe we could do better, but if we can get the data, it's a
# resource. Otherwise it isn't.
- path = f'{self.fullname}/{name}'
+ fullname_as_path = self.fullname.replace('.', '/')
+ path = f'{fullname_as_path}/{name}'
try:
self.zipimporter.get_data(path)
except OSError: