Issue #17907: touch up the code for imp.new_module().

This commit is contained in:
Brett Cannon 2013-06-14 22:26:30 -04:00
parent 15e489f7c5
commit a3c96154d2
8 changed files with 3700 additions and 3558 deletions

View file

@ -121,15 +121,6 @@ def _wrap(new, old):
_code_type = type(_wrap.__code__)
def new_module(name):
"""Create a new module.
The module is not entered into sys.modules.
"""
return type(_io)(name)
# Module-level locking ########################################################
# A dict mapping module names to weakrefs of _ModuleLock instances
@ -509,7 +500,7 @@ class _ModuleManager:
# This must be done before open() is called as the 'io' module
# implicitly imports 'locale' and would otherwise trigger an
# infinite loop.
self._module = new_module(self._name)
self._module = type(_io)(self._name)
# This must be done before putting the module in sys.modules
# (otherwise an optimization shortcut in import.c becomes wrong)
self._module.__initializing__ = True

View file

@ -1,9 +1,11 @@
"""Utility code for constructing importers, etc."""
from ._bootstrap import MAGIC_NUMBER
from ._bootstrap import cache_from_source
from ._bootstrap import module_to_load
from ._bootstrap import set_loader
from ._bootstrap import set_package
from ._bootstrap import source_from_cache
from ._bootstrap import _resolve_name
import functools