def module_for_loader(fxn):
 warnings.warn('The import system now takes care of this automatically.', DeprecationWarning, stacklevel=2)
 @functools.wraps(fxn)
 def module_for_loader_wrapper(self, fullname, *args, **kwargs):
  with _module_to_load(fullname) as module:
   module.__loader__ = self
   try:
    is_package = self.is_package(fullname)
   except (ImportError, AttributeError):
    pass
   else:
    if is_package:
     module.__package__ = fullname
    else:
     module.__package__ = fullname.rpartition('.')[0]
   return fxn(self, module, *args, **kwargs)
 return module_for_loader_wrapper

def module_for_loader ( fxn ) : warnings . warn ( 'The import system now takes care of this automatically.' , DeprecationWarning , stacklevel = 2 ) @ functools . wraps ( fxn ) def module_for_loader_wrapper ( self , fullname , * args , ** kwargs ) : with _module_to_load ( fullname ) as module : module . __loader__ = self try : is_package = self . is_package ( fullname ) except ( ImportError , AttributeError ) : pass else : if is_package : module . __package__ = fullname else : module . __package__ = fullname . rpartition ( '.' ) [ 0 ] return fxn ( self , module , * args , ** kwargs ) return module_for_loader_wrapper
decorator to handle selecting the proper module for loaders .