2015-12-13 05:25:34 +00:00
|
|
|
uncompyle6
|
2012-10-26 13:50:38 +00:00
|
|
|
==========
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-19 08:14:48 +00:00
|
|
|
A Python Byte-code Disassembler and Decompiler
|
|
|
|
|
2012-06-05 08:46:41 +00:00
|
|
|
|
|
|
|
Introduction
|
|
|
|
------------
|
|
|
|
|
2015-12-19 08:14:48 +00:00
|
|
|
A Python 2.x and 3.x byte-code decompiler.
|
|
|
|
*uncompyle6* translates Python byte-code back into equivalent Python
|
|
|
|
source code. It accepts byte-codes from Python version 2.5 to 2.7, and
|
|
|
|
runs on Python 2.6 and 2.7 and Python 3.4.
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-13 05:25:34 +00:00
|
|
|
The generated source is fairly readable: docstrings, lists, tuples and
|
|
|
|
hashes are somewhat pretty-printed.
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-15 07:06:21 +00:00
|
|
|
*uncompyle6* is based on John Aycock's generic small languages
|
2015-12-15 06:42:07 +00:00
|
|
|
compiler 'spark' (http://www.csr.uvic.ca/~aycock/python/) and his
|
2015-12-13 05:25:34 +00:00
|
|
|
prior work on a tool called 'decompyle'. This was improved by Hartmut Goebel
|
2015-12-15 06:42:07 +00:00
|
|
|
`http://www.crazy-compilers.com/`_
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-15 06:42:07 +00:00
|
|
|
# Additional note (3 July 2004):
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-15 06:42:07 +00:00
|
|
|
This software is no longer available from the original website.
|
|
|
|
However http://www.crazy-compilers.com/decompyle/ provides a
|
|
|
|
decompilation service.
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-15 06:42:07 +00:00
|
|
|
# Additional note (5 June 2012):
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2012-10-26 13:50:38 +00:00
|
|
|
The decompilation of python bytecode 2.5 & 2.6 is based on the work of
|
|
|
|
Eloi Vanderbeken. bytecode is translated to a pseudo 2.7 python bytecode
|
|
|
|
and then decompiled.
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-15 06:42:07 +00:00
|
|
|
# Additional note (12 Dec 2016):
|
2015-12-13 05:25:34 +00:00
|
|
|
|
2015-12-15 06:42:07 +00:00
|
|
|
I will be using this to deparse fragments of code inside my trepan_
|
|
|
|
debuggers_. For that, I need to record text fragements for all
|
2015-12-13 05:25:34 +00:00
|
|
|
byte-code offsets (of interest). This purpose although largely
|
|
|
|
compatible with the original intention is yet a little bit different.
|
|
|
|
|
|
|
|
|
2012-06-05 08:46:41 +00:00
|
|
|
Features
|
|
|
|
--------
|
|
|
|
|
2012-10-26 13:50:38 +00:00
|
|
|
- decompiles Python byte-code into equivalent Python source
|
|
|
|
- decompiles byte-code from Python version 2.5, 2.6, 2.7
|
|
|
|
- pretty-prints docstrings, hashes, lists and tuples
|
|
|
|
- reads directly from .pyc/.pyo files, bulk-decompile whole directories
|
|
|
|
- output may be written to file, a directory or to stdout
|
|
|
|
- option for including byte-code disassembly into generated source
|
2012-06-05 08:46:41 +00:00
|
|
|
|
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
|
2015-12-13 05:25:34 +00:00
|
|
|
This uses setup.py, so it follows the standard Python routine:
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-15 07:06:21 +00:00
|
|
|
::
|
|
|
|
|
2015-12-13 05:25:34 +00:00
|
|
|
python setup.py install # may need sudo
|
|
|
|
# or if you have pyenv:
|
|
|
|
python setup.py develop
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-13 05:25:34 +00:00
|
|
|
A GNU makefile is also provided so `make install` (possibly as root or
|
|
|
|
sudo) will do the steps above.
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-13 05:25:34 +00:00
|
|
|
Testing
|
|
|
|
-------
|
2012-06-05 08:46:41 +00:00
|
|
|
|
2015-12-19 08:14:48 +00:00
|
|
|
::
|
|
|
|
|
2015-12-18 22:07:35 +00:00
|
|
|
make check-2.7 # if running on Python 2.7
|
|
|
|
make check-3.4 # if running on Pyton 3.4
|
|
|
|
|
2015-12-13 05:25:34 +00:00
|
|
|
Testing right now is largely via utility `test/test_pythonlib.py`. A
|
|
|
|
GNU makefile has been added to smooth over setting running the right
|
|
|
|
command. If you have remake_ installed, you can see the list of all
|
|
|
|
tasks including tests via `remake --tasks`
|
2012-06-05 08:46:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
2015-12-13 05:25:34 +00:00
|
|
|
Run
|
|
|
|
|
2015-12-15 07:06:21 +00:00
|
|
|
::
|
|
|
|
|
2015-12-15 07:18:12 +00:00
|
|
|
./bin/uncompyle6 -h
|
|
|
|
./bin/pydisassemble -y
|
2015-12-13 05:25:34 +00:00
|
|
|
|
|
|
|
for usage help
|
2012-06-05 08:46:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
Known Bugs/Restrictions
|
|
|
|
-----------------------
|
|
|
|
|
2015-12-15 06:42:07 +00:00
|
|
|
Support Python 3 bytecode and syntax is lacking.
|
2012-10-26 13:50:38 +00:00
|
|
|
|
2015-12-19 08:14:48 +00:00
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
|
|
|
https://github.com/zrax/pycdc
|
|
|
|
|
|
|
|
|
2015-12-13 05:25:34 +00:00
|
|
|
.. _trepan: https://pypi.python.org/pypi/trepan
|
|
|
|
.. _debuggers: https://pypi.python.org/pypi/trepan3k
|
|
|
|
.. _remake: https://bashdb.sf.net/remake
|
2015-12-19 08:14:48 +00:00
|
|
|
.. _pycdc: https://github.com/zrax/pycdc
|