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)
     result = importing.load_source_module(space, w(modname), w_mod,
                                         filename, buf, write_pyc=False)
     return result
Пример #2
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)
     result = importing.load_source_module(space,
                                           w(modname),
                                           w_mod,
                                           filename,
                                           buf,
                                           write_pyc=False)
     return result
Пример #3
0
 def import_pyc_file(self, space, modname, filename, w_buf, pkgpath):
     w = space.wrap
     buf = space.str_w(w_buf)
     magic = importing._get_long(buf[:4])
     timestamp = importing._get_long(buf[4:8])
     if self.check_newer_pyfile(space, filename[:-1], timestamp):
         return self.import_py_file(space, modname, filename[:-1], w_buf,
                                    pkgpath)
     buf = buf[8:]  # XXX ugly copy, should use sequential read instead
     w_mod = w(Module(space, w(modname)))
     real_name = self.name + os.path.sep + filename
     importing._prepare_module(space, w_mod, real_name, pkgpath)
     result = importing.load_compiled_module(space, w(modname), w_mod,
                                             filename, magic, timestamp,
                                             buf)
     space.setattr(w_mod, w('__loader__'), space.wrap(self))
     return result
 def import_pyc_file(self, space, modname, filename, buf, pkgpath):
     w = space.wrap
     magic = importing._get_long(buf[:4])
     timestamp = importing._get_long(buf[4:8])
     if (self.check_newer_pyfile(space, filename[:-1], timestamp) or
         not self.check_compatible_mtime(space, filename, timestamp)):
         return self.import_py_file(space, modname, filename[:-1], buf,
                                    pkgpath)
     buf = buf[8:] # XXX ugly copy, should use sequential read instead
     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)
     result = importing.load_compiled_module(space, w(modname), w_mod,
                                             filename, magic, timestamp,
                                             buf)
     return result