ANN: unpyc3 - a python bytecode decompiler for Python3

Discussion in 'Python' started by Arnaud Delobelle, Sep 13, 2011.

  1. 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 == 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 == 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
     
    Arnaud Delobelle, Sep 13, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Al Ponomarev
    Replies:
    3
    Views:
    478
    Ken Cox [Microsoft MVP]
    May 3, 2004
  2. a a

    Python 2.4 decompiler

    a a, Sep 1, 2005, in forum: Python
    Replies:
    0
    Views:
    998
  3. Peter Hansen

    Re: Help...TT Python 2.4 decompiler

    Peter Hansen, Apr 12, 2006, in forum: Python
    Replies:
    0
    Views:
    838
    Peter Hansen
    Apr 12, 2006
  4. Arnaud Delobelle
    Replies:
    0
    Views:
    727
    Arnaud Delobelle
    Sep 14, 2011
  5. Andrew Berg
    Replies:
    0
    Views:
    353
    Andrew Berg
    Jun 16, 2012
Loading...

Share This Page