Commit eb2e0dd1 authored by Brett Cannon's avatar Brett Cannon

Move importlib's frozen importer over to rpartition for setting __package__.

parent 2b384942
......@@ -138,10 +138,9 @@ class FrozenImporter:
if cls.find_module(fullname) is None:
raise ImportError("{0} is not a frozen module".format(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]
module.__package__ = module.__name__
if not hasattr(module, '__path__'):
module.__package__ = module.__package__.rpartition('.')[0]
return module
......
......@@ -9,7 +9,7 @@ class LoaderTests(abc.LoaderTests):
with util.uncache('__hello__'):
module = machinery.FrozenImporter.load_module('__hello__')
check = {'__name__': '__hello__', '__file__': '<frozen>',
'__package__': None}
'__package__': ''}
for attr, value in check.items():
self.assertEqual(getattr(module, attr), value)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment