cdjc / goto

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tuple index out of range

jinx-13-13 opened this issue · comments

Your example file:
####################
from goto import goto

@goto
def test(n):

s = 0

label .myLoop

if n <= 0:
    return s
s += n
n -= 1

goto .myLoop

#######################
gives this error with python 3.7.3 :

In [3]: (executing file "goto_test.py")
Traceback (most recent call last):
File "goto_test.py", line 3, in
@goto
File "goto.py", line 35, in goto
labels, gotos = find_labels_and_gotos(c)
File "goto.py", line 125, in find_labels_and_gotos
global_name = c.co_names[num]
IndexError: tuple index out of range

commented

Thanks for seeing this. Looks like there was a change in 3.6 that changed the opcodes. And a change in 3.4 (leading edge when this code was written!) in the dis module (the dis.get_instructions() function) which will make the code a bit cleaner. Time for a bit of a refactor....

commented

Fixed in 79ad72b