MatthieuDartiailh/bytecode

read .pyc

Closed this issue · 3 comments

Does it support reading .pyc files? Get all bytecode instructions in .pyc by similar to Bytecode.from_code(code_obj)

No currently bytecode only operate on code objects.

I never tried to open a pyc and unmarshall it, but you could try that and grab the module code object to use with bytecode.

Would something like this work for you?

from pkgutil import read_code

with open("path/to.pyc", "rb") as f
    bc = Bytecode.from_code(read_code(f))

Thanks for your answers, it's very helpful for me