# HG changeset patch # User Paul Boddie # Date 1389653903 -3600 # Node ID fd113b9d829c2c5505e4bff9849cf5ee1f874eea # Parent 4ab6588b1998968476572e4b5d79b48777f1e57d Added failure tests involving closures. diff -r 4ab6588b1998 -r fd113b9d829c tests/failure/outer_stupid.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failure/outer_stupid.py Mon Jan 13 23:58:23 2014 +0100 @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +"Inspired by difflib._mdiff._line_iterator and its from_line variable." + +def outer(): + def inner(x): + if x: + y = 1 + return y + y = 2 + return inner + +result_1 = outer()(1) +result_2 = outer()(0) # CPython fails with UnboundLocalError in inner + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 4ab6588b1998 -r fd113b9d829c tests/failure/outer_stupid_explicit.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failure/outer_stupid_explicit.py Mon Jan 13 23:58:23 2014 +0100 @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +"Inspired by difflib._mdiff._line_iterator and its from_line variable." + +def outer(): + def inner(x): + if x: + y = 1 + return y + else: + return y + y = 2 + return inner + +result_1 = outer()(1) +result_2 = outer()(0) # CPython fails with UnboundLocalError in inner + +# vim: tabstop=4 expandtab shiftwidth=4