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:
Brett Cannon 2009-02-01 01:34:13 +00:00
parent e70485e7c1
commit 223a19d8b1
3 changed files with 51 additions and 14 deletions

View file

@ -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):