C++ python bytecode disassembler and decompiler
  • C++ 84.5%
  • Python 14.9%
  • CMake 0.5%
Find a file
Adrian Haensler deebbb044d add a test
2022-07-30 00:02:47 -05:00
.github/workflows Update MSVC version to make CI happy 2022-03-24 14:53:00 -07:00
bytes add RERAISE_A 2021-10-10 14:58:46 +05:30
scripts Addresses code review comments 2021-11-22 00:51:26 -05:00
tests add a test 2022-07-30 00:02:47 -05:00
.gitignore Issue-165 Added support for f-strings (literal string interpolation https://www.python.org/dev/peps/pep-0498/) 2020-10-17 20:52:57 +11:00
ASTNode.cpp Implement better handling for async for. 2020-10-21 19:32:20 +11:00
ASTNode.h fix for loops in 3.8 2022-07-08 20:25:13 -05:00
ASTree.cpp fix for loops in 3.8 2022-07-08 20:25:13 -05:00
ASTree.h Fixed imports, and restructured ifs to be "code blocks" 2010-09-07 21:32:34 -07:00
bytecode.cpp some fixes for 3.9 2022-07-08 17:45:07 -05:00
bytecode.h Disassembler changes in 3.10 under BPO-27129 2022-03-24 22:06:35 +01:00
bytecode_ops.inl add RERAISE_A 2021-10-10 14:58:46 +05:30
CMakeLists.txt fix for loops in 3.8 2022-07-08 20:25:13 -05:00
data.cpp Fix several undefined behavior issues identified by @nrathaus. 2018-01-28 15:37:44 -08:00
data.h Start requring C++11 with explicit virtual overrides. 2019-10-02 14:41:49 -07:00
FastStack.h Support for conditonal expression (if-expression) 2022-03-29 12:30:06 +02:00
LICENSE Added GPL v3 license file 2009-07-25 00:43:46 +00:00
pyc_code.cpp Add bytecode and disassembly support for Python 3.8. 2019-10-14 14:48:26 -07:00
pyc_code.h Add bytecode and disassembly support for Python 3.8. 2019-10-14 14:48:26 -07:00
pyc_module.cpp Style changes 2022-06-16 12:49:04 +01:00
pyc_module.h Add support for pycdas/pycdc using marshalled code objects 2022-06-15 11:33:11 +01:00
pyc_numeric.cpp Clean up some loops with range-based for. 2019-10-04 15:56:24 -07:00
pyc_numeric.h Use std::string instead of manual character buffers where applicable. 2019-10-02 16:01:54 -07:00
pyc_object.cpp Don't create special objects for NULL, just use NULL directly. 2017-07-05 16:36:04 -07:00
pyc_object.h Make PycRef<T> movable 2019-10-08 08:42:33 -07:00
pyc_sequence.cpp Remove unnecessary complexity and just use the base sequence type common 2018-04-28 11:37:13 -07:00
pyc_sequence.h Start requring C++11 with explicit virtual overrides. 2019-10-02 14:41:49 -07:00
pyc_string.cpp Minor style adjustments 2020-10-20 21:08:02 -07:00
pyc_string.h Minor style adjustments 2020-10-20 21:08:02 -07:00
pycdas.cpp Style changes 2022-06-16 12:49:04 +01:00
pycdc.cpp Style changes 2022-06-16 12:49:04 +01:00
PythonBytecode.txt Add bytecode documentation for 3.10 2021-10-10 11:57:14 -07:00
README.markdown Note code object support in readme 2022-06-15 11:37:07 +01:00

Decompyle++

A Python Byte-code Disassembler/Decompiler

Decompyle++ aims to translate compiled Python byte-code back into valid and human-readable Python source code. While other projects have achieved this with varied success, Decompyle++ is unique in that it seeks to support byte-code from any version of Python.

Decompyle++ includes both a byte-code disassembler (pycdas) and a decompiler (pycdc).

As the name implies, Decompyle++ is written in C++. If you wish to contribute, please fork us on github at https://github.com/zrax/pycdc

Building Decompyle++

  • Generate a project or makefile with CMake (See CMake's documentation for details)

    • The following options can be passed to CMake to control debug features:
      Option Description
      -DCMAKE_BUILD_TYPE=Debug Produce debugging symbols
      -DENABLE_BLOCK_DEBUG=ON Enable block debugging output
      -DENABLE_STACK_DEBUG=ON Enable stack debugging output
  • Build the generated project or makefile

    • For projects (e.g. MSVC), open the generated project file and build it
    • For makefiles, just run make
    • To run tests (on *nix or MSYS), run make check

Usage

To run pycdas, the PYC Disassembler: ./pycdas [PATH TO PYC FILE] The byte-code disassembly is printed to stdout.

To run pycdc, the PYC Decompiler: ./pycdc [PATH TO PYC FILE] The decompiled Python source is printed to stdout. Any errors are printed to stderr.

Marshalled code objects: Both tools support Python marshalled code objects, as output from marshal.dumps(compile(...)).

To use this feature, specify -c -v <version> on the command line - the version must be specified as the objects themelves do not contain version metadata.

Authors, Licence, Credits

Decompyle++ is the work of Michael Hansen and Darryl Pogue.

Additional contributions from:

  • charlietang98
  • Kunal Parmar
  • Olivier Iffrig
  • Zlodiy

It is released under the terms of the GNU General Public License, version 3; See LICENSE file for details.