Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13241 > unrolled thread

ANN: unpyc3 - a python bytecode decompiler for Python3

Started byArnaud Delobelle <arnodel@gmail.com>
First post2011-09-13 21:20 +0100
Last post2011-09-13 21:20 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  ANN: unpyc3 - a python bytecode decompiler for Python3 Arnaud Delobelle <arnodel@gmail.com> - 2011-09-13 21:20 +0100

#13241 — ANN: unpyc3 - a python bytecode decompiler for Python3

FromArnaud Delobelle <arnodel@gmail.com>
Date2011-09-13 21:20 +0100
SubjectANN: unpyc3 - a python bytecode decompiler for Python3
Message-ID<mailman.1084.1315945219.27778.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web