8000 [3.12] gh-121735: Fix module-adjacent references in zip files · python/cpython@c6dfba2 · GitHub
[go: up one dir, main page]

Skip to content

Commit c6dfba2

Browse files
committed
[3.12] gh-121735: Fix module-adjacent references in zip files
Applying the fix only and not the refactoring of the test suite.
1 parent 4514998 commit c6dfba2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Lib/importlib/resources/readers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ def files(self):
3131

3232
class ZipReader(abc.TraversableResources):
3333
def __init__(self, loader, module):
34-
_, _, name = module.rpartition('.')
35-
self.prefix = loader.prefix.replace('\\', '/') + name + '/'
34+
self.prefix = loader.prefix.replace('\\', '/')
35+
if loader.is_package(module):
36+
_, _, name = module.rpartition('.')
37+
self.prefix += name + '/'
3638
self.archive = loader.archive
3739

3840
def open_resource(self, resource):

0 commit comments

Comments
 (0)
0