summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/unboundlocal.py
blob: 5573da1665b61a66c543727990a789b938f01157 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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)