[Python-checkins] r69397 - in python/branches/py3k/Lib/importlib: _bootstrap.py test/frozen/test_loader.py
brett.cannon
python-checkins at python.org
Sat Feb 7 02:38:38 CET 2009
Author: brett.cannon
Date: Sat Feb 7 02:38:38 2009
New Revision: 69397
Log:
Move importlib's frozen importer over to rpartition for setting __package__.
Modified:
python/branches/py3k/Lib/importlib/_bootstrap.py
python/branches/py3k/Lib/importlib/test/frozen/test_loader.py
Modified: python/branches/py3k/Lib/importlib/_bootstrap.py
==============================================================================
--- python/branches/py3k/Lib/importlib/_bootstrap.py (original)
+++ python/branches/py3k/Lib/importlib/_bootstrap.py Sat Feb 7 02:38:38 2009
@@ -138,10 +138,9 @@
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
Modified: python/branches/py3k/Lib/importlib/test/frozen/test_loader.py
==============================================================================
--- python/branches/py3k/Lib/importlib/test/frozen/test_loader.py (original)
+++ python/branches/py3k/Lib/importlib/test/frozen/test_loader.py Sat Feb 7 02:38:38 2009
@@ -9,7 +9,7 @@
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)
More information about the Python-checkins
mailing list