Say I am in the python interpreter and define a function as follows:
def h(a):
return a
If I want to look at the bytecode (not a disassembly using dis), I can typically use h.func_code.co_code. Is there any other way to look at the bytecode?
For example, in the interpreter, if I just type h without making it a function call, I get the address of the function. Can I use that address to get the bytecode? Is there some other way?
Some additional info from the comments:
The app is written in python and packed using something like Py2App, cx_freeze, or py2exe. I played some tricks on the executable and now, when launched, the executable dumps me to a python command line. From there, I manually typed my function h into the interepeter.
Other attributes of h.func_code are present such as co_varnames, co_argcount, etc, but co_code is not.
If I type in h.func_code.co_code into the interpreter, I get 'code' object has no attribute 'co_code'.
UPDATE: From the comments again. As far as I can tell the opcodes have been remapped for the python interpreter that was shipped with the app.
h.func_code.co_codegood enough? Using the memory address is not going to be any easier.type? (Also,dircan be overriden by the object, don't bet your farm on its output.)co_codeattribute from the python interpreter. That would require a custom interpreter build. You could still just load all the python code into your own interpreter (just unzip the zipfiles in theContents/Resources/directory and put those on your path.