Example #1
0
def add_module(space, w_name):
    w_mod = check_sys_modules(space, w_name)
    if w_mod is None:
        w_mod = Module(space, w_name)
        init_extra_module_attrs(space, w_mod)
        space.sys.setmodule(w_mod)
    return w_mod
 def __init__(self, space, w_name):
     Module.__init__(self, space, w_name)
     init_extra_module_attrs(space, self)
     self.lazy = True
     self.lazy_initial_values_w = {}
     self.__class__.buildloaders()
     self.loaders = self.loaders.copy()  # copy from the class to the inst
     self.submodules_w = []
Example #3
0
def _prepare_module(space, w_mod, filename, pkgdir):
    space.sys.setmodule(w_mod)
    space.setattr(w_mod, space.newtext('__file__'),
                  space.newfilename(filename))
    space.setattr(w_mod, space.newtext('__doc__'), space.w_None)
    if pkgdir is not None:
        space.setattr(w_mod, space.newtext('__path__'),
                      space.newlist([space.newtext(pkgdir)]))
    init_extra_module_attrs(space, w_mod)