queglay wrote:i wonder why uncompyle2 (the python decompyler) produces these raise/assert errors in the decompiled files.
I've been doing some work on this recently, the problem is that uncompyle2 is a Python 2.7 program, while Ableton runs Python 2.5 internally... uncompyle2 has the ability to decompile Python 2.5 bytecode, but it converts it back into Python 2.7 code. Normally this isn't an issue, but there are a few new language features in 2.7 which it tries to use which don't exist in 2.5 - in this case, in 2.7 you can say:
Code: Select all
raise variable == True or Exception
and it will evaluate the expression "variable == True" - if the result of that is true, it won't do anything, if it is false, it will raise the exception. However, 2.5 didn't support this shorthand, so that same code converts to something like:
Code: Select all
if not variable == True:
raise Exception
I found another decompiler:
https://github.com/zrax/pycdc, which seems to output Python 2.5 code, but the code this produced was also buggy in different ways (and I couldn't get it to work properly even when I fixed the syntax errors). In the end, I managed to get a pretty much entirely working BrowserComponent.py by using the output from uncompyle2, but where there were any errors, looking at the pycdc output for that line and copying chunks over.
The chunk you are talking about ends up looking like this, which I found in the pycdc output:
Code: Select all
if children and is_folder or level < 1:
self._fit_content_lists(level + 2)
(child_contents, _) = self._contents[level + 1]
child_contents.assign_items(children)
I'm not sure if the code output by uncompyle2 would work properly in Python 2.7 or if it is buggy, I've not looked at it properly.
I'll share my file soon, along with some pretty exciting (I think
) Push hacks I've developed
Would be great if we can find a proper Py2.5 decompiler (I notice there's a web based service at
http://www.crazy-compilers.com/decompyle/, apparently this is what
https://github.com/tswr/UnPyc became - obviously the author realised open source isn't that profitable
) - I have tried all the ones I could find and none worked properly, however the combo of uncompyle and pycdc will do for now. It would be even cooler if we could hack Ableton to run Python 2.7 internally... and even cooler still if Ableton just released the source PY files
!