MCPcopy Create free account
hub / github.com/pyload/pyload / load_bytecode

Method load_bytecode

module/lib/jinja2/bccache.py:53–70  ·  view source on GitHub ↗

Loads bytecode from a file or file like object.

(self, f)

Source from the content-addressed store, hash-verified

51 self.code = None
52
53 def load_bytecode(self, f):
54 """Loads bytecode from a file or file like object."""
55 # make sure the magic header is correct
56 magic = f.read(len(bc_magic))
57 if magic != bc_magic:
58 self.reset()
59 return
60 # the source code of the file changed, we need to reload
61 checksum = pickle.load(f)
62 if self.checksum != checksum:
63 self.reset()
64 return
65 # now load the code. Because marshal is not able to load
66 # from arbitrary streams we have to work around that
67 if isinstance(f, file):
68 self.code = marshal.load(f)
69 else:
70 self.code = marshal.loads(f.read())
71
72 def write_bytecode(self, f):
73 """Dump the bytecode into the file or file like object passed."""

Callers 2

bytecode_from_stringMethod · 0.95
load_bytecodeMethod · 0.45

Calls 3

resetMethod · 0.95
readMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected