fixed possibility of StopIteration Exception to happen with wrong written ternary operators

This commit is contained in:
David Halter
2012-08-23 02:25:44 +02:00
parent 09e9a85382
commit 2c66af7868
3 changed files with 10 additions and 2 deletions

View File

@@ -1217,7 +1217,10 @@ def follow_call_list(call_list):
if str(call.name) == 'if':
# Ternary operators.
while True:
call = next(calls_iterator)
try:
call = next(calls_iterator)
except StopIteration:
break
try:
if str(call.name) == 'else':
break

View File

@@ -56,5 +56,10 @@ try:
#? str()
""
# wrong ternary
a = 1 if
#? int()
a
#? []
int()).

View File

@@ -32,5 +32,5 @@ el = list(evaluate.get_names_for_scope(1))[0][1]
el = list(evaluate.get_names_for_scope())[0][1]
# TODO here should stand evaluate.Instance() and so on.
##? []
#?
el = list(evaluate.get_names_for_scope())[0][1][0]