mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
Fix importlib.machinery.FrozenImporter.load_module() to set __package__
properly. Discovered by also moving the loader tests over to importlib.test.abc.LoaderTests.
This commit is contained in:
parent
e70485e7c1
commit
223a19d8b1
3 changed files with 51 additions and 14 deletions
|
@ -137,7 +137,12 @@ class FrozenImporter:
|
|||
"""Load a frozen module."""
|
||||
if cls.find_module(fullname) is None:
|
||||
raise ImportError("{0} is not a frozen module".format(fullname))
|
||||
return imp.init_frozen(fullname)
|
||||
module = imp.init_frozen(fullname)
|
||||
if hasattr(module, '__path__'):
|
||||
module.__package__ = module.__name__
|
||||
elif '.' in module.__name__:
|
||||
module.__package__ = module.__name__.rsplit('.', 1)[0]
|
||||
return module
|
||||
|
||||
|
||||
class ChainedImporter(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue