mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Move importlib's frozen importer over to rpartition for setting __package__.
This commit is contained in:
parent
2b3849425f
commit
eb2e0dd19d
2 changed files with 4 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue