Kara-Moon Forum
March 28, 2024, 02:20:01 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: You can go back to the main site here: Kara-Moon site
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [BUG] Crash on empty MSet  (Read 4594 times)
neclepsio
Jr. Member
*
Posts: 5


« 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 
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #1 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.
« Last Edit: September 21, 2014, 04:39:44 PM by bvdp » Logged

My online life: http://www.mellowood.ca
neclepsio
Jr. Member
*
Posts: 5


« Reply #2 on: September 21, 2014, 05:57:06 PM »

Wow, a free upgrade!  wOO

Thank you for the solution.
Ignazio
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #3 on: September 21, 2014, 08:45:39 PM »

Wow, a free upgrade!  wOO


Shhhh! Now everyone will be wanting one  Cheesy
Logged

My online life: http://www.mellowood.ca
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.046 seconds with 19 queries.