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
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
def load_compiled(space, w_modulename, filename, w_file=None): w_mod = Module(space, w_modulename) importing._prepare_module(space, w_mod, filename, None) return _run_compiled_module(space, w_modulename, filename, w_file, w_mod, check_afterwards=True)
def load_source(space, w_modulename, w_filename, w_file=None): filename = space.str_w(w_filename) stream = get_file(space, w_file, filename, "U") w_mod = space.wrap(Module(space, w_modulename)) importing._prepare_module(space, w_mod, filename, None) importing.load_source_module(space, w_modulename, w_mod, filename, stream.readall()) if space.is_w(w_file, space.w_None): stream.close() return w_mod
def load_source(space, w_modulename, w_filename, w_file=None): filename = space.str0_w(w_filename) stream = get_file(space, w_file, filename, 'U') w_mod = space.wrap(Module(space, w_modulename)) importing._prepare_module(space, w_mod, filename, None) importing.load_source_module(space, w_modulename, w_mod, filename, stream.readall()) if space.is_w(w_file, space.w_None): stream.close() return w_mod
def load_source(space, w_modulename, w_filename, w_file=None): filename = space.fsencode_w(w_filename) stream = get_file(space, w_file, filename, 'U') w_mod = Module(space, w_modulename) importing._prepare_module(space, w_mod, filename, None) w_mod = importing.load_source_module(space, w_modulename, w_mod, filename, stream.readall(), stream.try_to_find_file_descriptor()) if space.is_none(w_file): stream.close() return w_mod
def load_source(space, w_modulename, w_filename, w_file=None): filename = space.str0_w(w_filename) stream = get_file(space, w_file, filename, 'U') w_mod = space.wrap(Module(space, w_modulename)) importing._prepare_module(space, w_mod, filename, None) w_mod = importing.load_source_module( space, w_modulename, w_mod, filename, stream.readall(), stream.try_to_find_file_descriptor()) if space.is_none(w_file): stream.close() return w_mod
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 not self.can_use_pyc(space, filename, magic, timestamp): return None buf = buf[8:] # XXX ugly copy, should use sequential read instead w_mod = w(Module(space, w(modname))) real_name = self.filename + 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, real_name, magic, timestamp, buf) 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 not self.can_use_pyc(space, filename, magic, timestamp): return None buf = buf[8:] # XXX ugly copy, should use sequential read instead w_mod = w(Module(space, w(modname))) real_name = self.filename + 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) w_result = importing.load_compiled_module(space, w(modname), w_mod, filename, magic, timestamp, buf) return w_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
def load_compiled(space, w_modulename, w_filename, w_file=None): filename = space.str_w(w_filename) stream = get_file(space, w_file, filename, 'rb') w_mod = space.wrap(Module(space, w_modulename)) importing._prepare_module(space, w_mod, filename, None) magic = importing._r_long(stream) timestamp = importing._r_long(stream) importing.load_compiled_module( space, w_modulename, w_mod, filename, magic, timestamp, stream.readall()) if space.is_w(w_file, space.w_None): stream.close() return w_mod
def import_pyc_file(self, space, modname, filename, buf, pkgpath): if len(buf) < 8: raise oefmt(get_error(space), "bad pyc data") magic = importing._get_long(buf[:4]) timestamp = importing._get_long(buf[4:8]) if not self.can_use_pyc(space, filename, magic, timestamp): return None buf = buf[8:] # XXX ugly copy, should use sequential read instead 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) w_result = importing.load_compiled_module(space, space.newtext(modname), w_mod, filename, magic, timestamp, buf) return w_result
def import_pyc_file(self, space, modname, filename, buf, pkgpath): # a field are four bytes # | magic | 0b00 | timestamp | size # traditional timestamp based pyc # | magic | 0b01 | hash1 | hash2 # unchecked # | magic | 0b11 | hash1 | hash2 # checked if len(buf) < 16: raise oefmt(get_error(space), "bad pyc data") magic = importing._get_long(buf[:4]) if not self.can_use_pyc(space, filename, magic, buf): return None buf = buf[16:] # XXX ugly copy, should use sequential read instead 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) result = importing.load_compiled_module(space, space.newtext(modname), w_mod, real_name, magic, buf) return result
def load_compiled(space, w_modulename, filename, w_file=None): w_mod = space.wrap(Module(space, w_modulename)) importing._prepare_module(space, w_mod, filename, None) return _run_compiled_module(space, w_modulename, filename, w_file, w_mod, check_afterwards=True)
def load_compiled(space, w_modulename, filename, w_file=None): w_mod = space.wrap(Module(space, w_modulename)) importing._prepare_module(space, w_mod, filename, None) _run_compiled_module(space, w_modulename, filename, w_file, w_mod) return w_mod