Kara-Moon Forum

Developers & Technology => Musical MIDI Accompaniment (MMA) => Topic started by: neclepsio on September 21, 2014, 12:45:17 PM



Title: [BUG] Crash on empty MSet
Post by: neclepsio on September 21, 2014, 12:45:17 PM
If using an empty MSet there is a crash in python.

MSet test
EndMSet
$test


Traceback (most recent call last):
  File "mma-bin-14.07\mma.py", line 74, in <module>
    import MMA.main
  File "d:\Users\xxx\Desktop\mma\mma-bin-14.07\MMA\main.py", line 143, in <module>
    MMA.parse.parseFile(f)
  File "d:\Users\xxx\Desktop\mma\mma-bin-14.07\MMA\parse.py", line 102, in parseFile
    parse(f)
  File "d:\Users\xxx\Desktop\mma\mma-bin-14.07\MMA\parse.py", line 142, in parse
    action = l[0].upper()      # 1st arg in line
IndexError: list index out of range

I think an empty MSet should be legal (I can define them, then fill later), but even if not there should be an error, and not a crash.

Thank you,
Ignazio 


Title: Re: [BUG] Crash on empty MSet
Post by: bvdp on September 21, 2014, 04:34:57 PM
You win a free upgrade. Yup, it's a bug. It applies to simple SET macros as well.

Easy to fix. In line 125 of parse.mma right after:

Code:
    while 1:
        curline = inpath.read()

        if curline is None:   # eof, exit parser
            break

        l = macros.expand(curline)

 add the lines:

Code:
        if not l:
            continue

This way empty macros are skipped over. BTW, if you are new to python make sure you have proper indentation (which doesn't show up here). Shout if you need help.


Title: Re: [BUG] Crash on empty MSet
Post by: neclepsio on September 21, 2014, 05:57:06 PM
Wow, a free upgrade!  :;

Thank you for the solution.
Ignazio


Title: Re: [BUG] Crash on empty MSet
Post by: bvdp on September 21, 2014, 08:45:39 PM
Wow, a free upgrade!  :;


Shhhh! Now everyone will be wanting one  :D