(spec, module)
return module
Execute the spec's specified module in an existing module's namespace.
Execute the spec's specified module in an existing module's namespace.
Execute the spec s specified module in an existing module s namespace .
def _exec(spec, module):
    """Execute the spec's specified module in an existing module's namespace."""
    name = spec.name
    with _ModuleLockManager(name):
        if sys.modules.get(name) is not module:
            msg = 'module {!r} not in sys.modules'.format(name)
            raise ImportError(msg, name=name)
        try:
            if spec.loader is None:
                if spec.submodule_search_locations is None:
                    raise ImportError('missing loader', name=spec.name)
                # Namespace package.
                _init_module_attrs(spec, module, override=True)
            else:
                _init_module_attrs(spec, module, override=True)
                if not hasattr(spec.loader, 'exec_module'):
                    msg = (f"{_object_name(spec.loader)}.exec_module() not found; "
                           "falling back to load_module()")
                    _warnings.warn(msg, ImportWarning)
                    spec.loader.load_module(name)
                else:
                    spec.loader.exec_module(module)
        finally:
            # Update the order of insertion into sys.modules for module
            # clean-up at shutdown.
            module = sys.modules.pop(spec.name)
            sys.modules[spec.name] = module
    return module
def _exec ( spec , module ) : name = spec . name with _ModuleLockManager ( name ) : if sys . modules . get ( name ) is not module : msg = 'module {!r} not in sys.modules' . format ( name ) raise ImportError ( msg , name = name ) try : if spec . loader is None : if spec . submodule_search_locations is None : raise ImportError ( 'missing loader' , name = spec . name ) # Namespace package. _init_module_attrs ( spec , module , override = True ) else : _init_module_attrs ( spec , module , override = True ) if not hasattr ( spec . loader , 'exec_module' ) : msg = ( f"{_object_name(spec.loader)}.exec_module() not found; " "falling back to load_module()" ) _warnings . warn ( msg , ImportWarning ) spec . loader . load_module ( name ) else : spec . loader . exec_module ( module ) finally : # Update the order of insertion into sys.modules for module # clean-up at shutdown. module = sys . modules . pop ( spec . name ) sys . modules [ spec . name ] = module return module