Skip to content

figment/unpyc3

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

unpyc3

Decompiler for Python 3.3 (forked from https://code.google.com/p/unpyc3)

Original README

The aim is to be able to recreate Python3 source code from code objects. Current version is able to decompile itself successfully :). It has been tested with Python 3.3 only.

It currently reconstructs most of Python 3 constructs but probably needs to be tested more thoroughly. All feedback welcome.

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
>>>

Unpyc3 is made of a single python module. Download unpyc3.py and try it now!

the unpyc3 module is able de decompile itself! (try import unpyc3; unpyc3.decompile(unpyc3)) so theorically I could just distribute the .pyc file.

TODO:

  • Support for keyword-only arguments
  • Handle assert statements
  • Show docstrings for functions and modules
  • Nice spacing between function/class declarations

Addendum

About

Decompiler for Python 3.3 (forked from https://code.google.com/p/unpyc3)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages