Le 13/09/11 22:20, Arnaud Delobelle a écrit :
Hi, trying your code, I have had numbers of errors: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. File "unpyc3.py", line 55, in <module> SETUP_WITH, NameError: name 'SETUP_WITH' is not defined commented it File "unpyc3.py", line 58, in <module> STORE_DEREF, DELETE_DEREF, NameError: name 'DELETE_DEREF' is not defined commented it File "unpyc3.py", line 96, in dec_module stream = open(pyc_path, "rb") UnboundLocalError: local variable 'pyc_path' referenced before assignment change pyc_path to path File "unpyc3.py", line 98, in dec_module code = Code(code_obj) File "unpyc3.py", line 210, in __init__ for v in code_obj.co_cellvars + code_obj.co_freevars] AttributeError: 'NoneType' object has no attribute 'co_cellvars' ... Cheers |
-- http://mail.python.org/mailman/listinfo/python-list