diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-02-01 01:34:13 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-02-01 01:34:13 (GMT) |
commit | 223a19d8b19b02fb3200f92665dfc6b257ee14bb (patch) | |
tree | a9ebfd5a713349af7f4cd7a7e38702d3fbc86015 /Lib/importlib/_bootstrap.py | |
parent | e70485e7c1e9f769679328ee87f9e61bbd892ed8 (diff) | |
download | cpython-223a19d8b19b02fb3200f92665dfc6b257ee14bb.zip cpython-223a19d8b19b02fb3200f92665dfc6b257ee14bb.tar.gz cpython-223a19d8b19b02fb3200f92665dfc6b257ee14bb.tar.bz2 |
Fix importlib.machinery.FrozenImporter.load_module() to set __package__
properly. Discovered by also moving the loader tests over to
importlib.test.abc.LoaderTests.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index c1d09dd..d2d5d34 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -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): |