ANN: unpyc3 - a python bytecode decompiler for Python3
Arnaud Delobelle
arnodel at gmail.com
Tue Sep 13 16:20:16 EDT 2011
Hi all,
Unpyc3 can recreate Python3 source code from code objects, function
source code from function objects, and module source code from .pyc
files. The current version is able to decompile itself successfully
:). It has been tested with Python3.2 only.
It currently reconstructs most of Python 3 (see TODO below) constructs
but probably needs to be tested more thoroughly. All feedback welcome.
Unpyc3 is a single file and is available at http://code.google.com/p/unpyc3/
Example:
>>> from unpyc3 import decompile
>>> def foo(x, y, z=3, *args):
... global g
... for i, j in zip(x, y):
... if z == i + j or args[i] == j:
... g = i, j
... return
...
>>> print(decompile(foo))
def foo(x, y, z=3, *args):
global g
for i, j in zip(x, y):
if z == i + j or args[i] == j:
g = i, j
return
TODO:
* Support for keyword-only arguments
* Handle assert statements
* Show docstrings for functions and modules
* Nice spacing between function/class declarations
Have fun!
Note: unpyc3 is totally unrelated to another project called "unpyc"
which I discovered when I tried to register the same project name on
google code.
--
Arnaud
More information about the Python-list
mailing list