Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
py_compile issue
#1
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 ?
Reply
#2
Syntax errors shown in one place may indicate a problem earlier in the file, often on the previous line.
Johb likes this post
Reply
#3
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
Johb likes this post
Reply
#4
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
Reply
#5
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.
Johb likes this post
Reply
#6
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.
Reply
#7
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
Reply
#8
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 ?
Reply
#9
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+?
Larz60+ likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  py_compile spouted this weird output Klar 4 3,418 Dec-13-2017, 05:35 PM
Last Post: Klar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020