2014-01-13 | Paul Boddie | raw annotate files changeset graph | Added failure tests involving closures. | syspython-as-target |
1 #!/usr/bin/env python 2 3 "Inspired by difflib._mdiff._line_iterator and its from_line variable." 4 5 def outer(): 6 def inner(x): 7 if x: 8 y = 1 9 return y 10 else: 11 return y 12 y = 2 13 return inner 14 15 result_1 = outer()(1) 16 result_2 = outer()(0) # CPython fails with UnboundLocalError in inner 17 18 # vim: tabstop=4 expandtab shiftwidth=4