Python Forum
py_compile issue - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: py_compile issue (/thread-30697.html)



py_compile issue - Johb - Nov-01-2020

Hi guys,

I want to edit a python file required by an hardware device I use for making music. The original file is a .pyc which I decompiled using uncompyle6. I copied the text in Wordpad and saved as a py file. Then I try to compile as pyc with the py_compile function but even without making any modification to the script, it keeps showing the following message :
File "melodic_pattern.py", line 126
def _get_note_info(self, (octave, note), root_note, channel=0):
^
SyntaxError: invalid syntax

What can I do to make it work ?


RE: py_compile issue - bowlofred - Nov-01-2020

Syntax errors shown in one place may indicate a problem earlier in the file, often on the previous line.


RE: py_compile issue - Larz60+ - Nov-01-2020

you must pass the tuple as a unit, and break in the function

example:
def myfunc(atuple):
    for item in atuple:
        print(item)

lunch = ('hot', 'dog')
myfunc(lunch)
Output:
hot dog



RE: py_compile issue - Johb - Nov-01-2020

Thanks for your help. Can it be that the decompiling process messes with the code ?
The problem is I have zero coding knowledge. Could you have a look and see if you can find anything ? It can be found here : https://www.online-python.com/XNf8JAaxtO


RE: py_compile issue - Larz60+ - Nov-01-2020

what did you use to decompile?
what is the name of the original product, and what exactly does this bit of code do.
Please tell me everything you can so that I have a idea of what I'm trying to do.
I'll help if i can, but only if I know more about what I am trying to do.


RE: py_compile issue - Johb - Nov-02-2020

Wow ! Thanks a lot for your assistance ! It'd be a hell of a service if you could make it work !

That file is used by a MIDI controller called Ableton Push. The main function of the device is to trigger sounds or notes when you hit the pads. The file I'm trying to edit defines preset musical scales (lines 38 to 63) and I want to add more of these. Like previously said the problem is that without even doing anything I get an error code when trying to compile back to pyc.

I used uncompyle6 v3.7.4 to decompile.


RE: py_compile issue - Larz60+ - Nov-02-2020

the code you show contains imports of another module which must be present in order for your code to work
specifically: ableton.v2.base.py
do you have that code.
It looks like the decompile also gave you the python code, and I wonder if you need a .pyc at all.
what makes you think so?

That software is licensed. I won't mess with it, but others will.
Google the following, you may find exactly what you are looking for.
"Ableton Push" site:hackaday.com
good luck


RE: py_compile issue - Johb - Nov-02-2020

Alright, thanks for the help, I'll look into that.

Regarding the pyc, I believe I don't need it. In a previous version of the host program, py files used to work just as fine. In that case it doesn't but it's more likely the syntax error issue rather than a py/pyc thing.

What's puzzling me here is why the original pyc works and the decompiled version doesn't. Is there something in the decompiling process I may have done wrong ?


RE: py_compile issue - jefsummers - Nov-02-2020

Just my 2c - do we know the version of Python the program was written in? Might it have been 2.7, and now won't run run on Python 3+?