summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/try-reraise2.py
blob: 9ab8d9c0995df57f18b1a2083a9d5728591e048b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Reraise not the latest occured exception
def f():
    try:
        raise ValueError("val", 3)
    except:
        try:
            raise TypeError
        except:
            try:
                try:
                    raise AttributeError
                except:
                    pass
                raise
            except TypeError:
                pass
        # This should raise original ValueError, not the most recently occurred AttributeError
        raise

try:
    f()
except ValueError as e:
    print(repr(e))