Skip to content
R. Bernstein edited this page Dec 13, 2015 · 1 revision

So what's with this code? .

There seem to be lots of forks with duplicated and slightly different code around. To some extent that happens with any abandoned project. Or a project that is this difficult and such a time waster as this is, and one which is maintained outside and in parallel with CPython. Finally, I think different people have different goals which causes divergence.

So let's start with the PyPI package uncompyle2. As advertised, works for Python 2.7 and only decompiles Python 2.7. The author, Hartmut Goebel, is different than the package index owner Thomas Grainger, but I am not sure either is maintaining this as open-source code The last release comes from June 2014 which is over two years ago. From PyPI though you can get the source code to that package.

There are various forks of the code on github though such as this, this, and this. I'm sure there are a lot more. Again not much activity in any of these recently.

What's odd about this code base I think it started out supporting multiple bytecode versions. The project clearly predates Python 2.7. There is a version in github by Mysterie that supports Python bytecodes from Python 2.5 to Python 2.7, although the code itself only runs with Python 2.7.

And this brings us to unpyc which was exported from the defunct code.google.com version and is stated to be a fork of decompyle-2.3.2. That has disassemblers, bytecode magics and de-marshallers going back to Python 1.5!

But what about decompilers for Python3? There are some that are ports of unpyc to Python3, and somethat are ports of uncompyle2 to Python3. The one by DarkFenX deserves mention in that he's cleaned up the code, modernized it and made the pieces smaller and more modules.

I should note though, that handling multiple Python bytecode versions is harder than handling the decompile for this version of Python along. If you only care about decompiling version X using Python version X, things are simpler. Specifically you can use the disassembler and code object de-marshallizer that comes with Python.

In my intended used inside a debugger, that is the situation.

That said, I don't mind extending handling the additional other versions provided it can be done in a controlled. way.

But I have a gut feeling that it would be nice of more of the forks came together. I believe this a general principle, but also it is expedient: none of us have the time it takes to support this fully.