C++ python bytecode disassembler and decompiler
  • C++ 84.5%
  • Python 14.9%
  • CMake 0.5%
Find a file
2023-02-28 15:49:12 -08:00
.github/workflows Update CodeQL configuration 2023-02-27 13:12:11 -08:00
bytes Add basic opcode (disassembly) support for Python 3.11 2023-01-19 11:32:07 -08:00
scripts Add simple_const tests for Python 3.8-3.11, and handle Python 3.11 RESUME opcode 2023-01-24 10:25:10 -08:00
tests Add PUSH_NULL, PRECALL_A, CALL_A support (#324) 2023-02-28 15:48:33 -08: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 Use deque instead of set 2023-02-13 19:25:45 -08:00
ASTree.cpp Fixup unrelated changes from PR 2023-02-28 15:49:12 -08:00
ASTree.h Fixed imports, and restructured ifs to be "code blocks" 2010-09-07 21:32:34 -07:00
bytecode.cpp Print out frozenset in disasm too 2023-02-13 19:33:25 -08:00
bytecode.h Handle CACHE instructions in decompyle, and suppress them in disassembly by default. 2023-01-19 14:50:55 -08:00
bytecode_ops.inl Add basic opcode (disassembly) support for Python 3.11 2023-01-19 11:32:07 -08:00
CMakeLists.txt Add basic opcode (disassembly) support for Python 3.11 2023-01-19 11:32:07 -08: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 Fix LOAD_GLOBAL and cell var references in Python 3.11+ 2023-01-19 13:05:06 -08:00
pyc_code.h Fix LOAD_GLOBAL and cell var references in Python 3.11+ 2023-01-19 13:05:06 -08:00
pyc_module.cpp Add basic opcode (disassembly) support for Python 3.11 2023-01-19 11:32:07 -08:00
pyc_module.h Add basic opcode (disassembly) support for Python 3.11 2023-01-19 11:32:07 -08:00
pyc_numeric.cpp Reduce unnecessary uses of std::list 2022-12-01 11:35:14 -08:00
pyc_numeric.h Reduce unnecessary uses of std::list 2022-12-01 11:35:14 -08: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 cast() checked by default and add try_cast() for cases where a cast 2022-12-01 16:13:31 -08:00
pyc_sequence.cpp Reduce code duplication between PycSet/PycTuple/PycList 2023-02-16 22:10:44 -08:00
pyc_sequence.h Reduce code duplication between PycSet/PycTuple/PycList 2023-02-16 22:10:44 -08:00
pyc_string.cpp For String Refs, inherit the type of the reffed string object. 2022-12-01 11:42:31 -08:00
pyc_string.h Minor style adjustments 2020-10-20 21:08:02 -07:00
pycdas.cpp Properly output frozenset object in pycdas 2023-02-13 19:26:30 -08:00
pycdc.cpp Style changes 2022-06-16 12:49:04 +01:00
PythonBytecode.txt Merge <3.11 VarNames and >=3.11 Locals+Names into a single variable for simplicity. 2023-01-19 11:32:07 -08:00
README.markdown Update README.markdown 2022-10-02 15:44:29 +05:30

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