From 7324e6cda8abae54111c5f886c8069812fb040bc Mon Sep 17 00:00:00 2001 From: Marion Date: Sat, 02 Nov 2013 10:46:46 +0000 Subject: Fixes #4641 "Save as Python fails when stack is empty" Check whether the list is empty before accessing an element. --- diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py index 458b886..c7d903d 100644 --- a/TurtleArt/taexportpython.py +++ b/TurtleArt/taexportpython.py @@ -116,7 +116,7 @@ def _action_stack_to_python(block, tw, name="start"): # traverse the block stack and get the AST for every block ast_list = _walk_action_stack(block, tw.lc) - if not isinstance(ast_list[-1], ast.Yield): + if not ast_list or not isinstance(ast_list[-1], ast.Yield): ast_list.append(ast_yield_true()) action_stack_ast = ast.Module(body=ast_list) #debug_output(str(action_stack_ast)) -- cgit v0.9.1