1.1 --- a/common.py Thu Jan 24 18:28:15 2019 +0100
1.2 +++ b/common.py Thu Jan 24 19:12:29 2019 +0100
1.3 @@ -579,10 +579,14 @@
1.4 # <t2> = <t1>.next
1.5 # try:
1.6 # while True:
1.7 - # <var>... = <t2>()
1.8 - # ...
1.9 - # except StopIteration:
1.10 + # try:
1.11 + # <var>... = <t2>()
1.12 + # except StopIteration:
1.13 + # raise LoopExit
1.14 + # {n.body}
1.15 + # except LoopExit:
1.16 # {n.else_}
1.17 + # pass
1.18
1.19 compiler.ast.Assign(
1.20 [compiler.ast.AssName(t2, "OP_ASSIGN")],
1.21 @@ -592,15 +596,18 @@
1.22 compiler.ast.While(
1.23 compiler.ast.Name("True"),
1.24 compiler.ast.Stmt([
1.25 - compiler.ast.Assign(
1.26 - [n.assign],
1.27 - compiler.ast.CallFunc(
1.28 - compiler.ast.Name(t2),
1.29 - []
1.30 - )),
1.31 + compiler.ast.TryExcept(
1.32 + compiler.ast.Assign(
1.33 + [n.assign],
1.34 + compiler.ast.CallFunc(
1.35 + compiler.ast.Name(t2),
1.36 + [])),
1.37 + [(compiler.ast.Name("StopIteration"), None,
1.38 + compiler.ast.Raise(compiler.ast.Name("LoopExit")))],
1.39 + None),
1.40 n.body]),
1.41 None),
1.42 - [(compiler.ast.Name("StopIteration"), None, n.else_ or compiler.ast.Pass())],
1.43 + [(compiler.ast.Name("LoopExit"), None, n.else_ or compiler.ast.Pass())],
1.44 None)
1.45 ])
1.46