diff options
Diffstat (limited to 'tests/basics/unboundlocal.py')
| -rw-r--r-- | tests/basics/unboundlocal.py | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/tests/basics/unboundlocal.py b/tests/basics/unboundlocal.py new file mode 100644 index 000000000..5573da166 --- /dev/null +++ b/tests/basics/unboundlocal.py @@ -0,0 +1,19 @@ +# locals referenced before assignment + +def f1(): +    print(x) +    x = 1 + +def f2(): +    for i in range(0): +        print(i) +    print(i) + +def check(f): +    try: +        f() +    except NameError: +        print("NameError") + +check(f1) +check(f2) | 
