Example #1
0
 def import_py_file(self, space, modname, filename, buf, pkgpath):
     w = space.wrap
     w_mod = w(Module(space, w(modname)))
     real_name = self.name + os.path.sep + self.corr_zname(filename)
     space.setattr(w_mod, w('__loader__'), space.wrap(self))
     importing._prepare_module(space, w_mod, real_name, pkgpath)
     code_w = importing.parse_source_module(space, filename, buf)
     importing.exec_code_module(space, w_mod, code_w)
     return w_mod
Example #2
0
 def import_py_file(self, space, modname, filename, buf, pkgpath):
     w_mod = Module(space, space.newtext(modname))
     real_name = self.filename + os.path.sep + self.corr_zname(filename)
     space.setattr(w_mod, space.newtext('__loader__'), self)
     importing._prepare_module(space, w_mod, real_name, pkgpath)
     co_filename = self.make_co_filename(filename)
     code_w = importing.parse_source_module(space, co_filename, buf)
     importing.exec_code_module(space, w_mod, code_w, co_filename, None)
     return w_mod
Example #3
0
 def import_py_file(self, space, modname, filename, buf, pkgpath):
     w = space.wrap
     w_mod = w(Module(space, w(modname)))
     real_name = self.name + os.path.sep + self.corr_zname(filename)
     space.setattr(w_mod, w('__loader__'), space.wrap(self))
     importing._prepare_module(space, w_mod, real_name, pkgpath)
     code_w = importing.parse_source_module(space, filename, buf)
     importing.exec_code_module(space, w_mod, code_w)
     return w_mod
Example #4
0
def PyImport_ExecCodeModuleEx(space, name, w_code, pathname):
    """Like PyImport_ExecCodeModule(), but the __file__ attribute of
    the module object is set to pathname if it is non-NULL."""
    code = space.interp_w(PyCode, w_code)
    w_name = space.wrap(rffi.charp2str(name))
    if pathname:
        pathname = rffi.charp2str(pathname)
    else:
        pathname = code.co_filename
    w_mod = importing.add_module(space, w_name)
    space.setattr(w_mod, space.wrap('__file__'), space.wrap(pathname))
    importing.exec_code_module(space, w_mod, code)
    return w_mod
Example #5
0
def PyImport_ExecCodeModuleEx(space, name, w_code, pathname):
    """Like PyImport_ExecCodeModule(), but the __file__ attribute of
    the module object is set to pathname if it is non-NULL."""
    code = space.interp_w(PyCode, w_code)
    w_name = space.wrap(rffi.charp2str(name))
    if pathname:
        pathname = rffi.charp2str(pathname)
    else:
        pathname = code.co_filename
    w_mod = importing.add_module(space, w_name)
    space.setattr(w_mod, space.wrap('__file__'), space.wrap(pathname))
    importing.exec_code_module(space, w_mod, code)
    return w_mod