try-reraise2.py 745 Bytes
Newer Older
1
2
3
4
5
6
# Reraise not the latest occured exception
def f():
    try:
        raise ValueError("val", 3)
    except:
        try:
7
            print(1)
8
9
            raise TypeError
        except:
10
            print(2)
11
            try:
12
                print(3)
13
                try:
14
                    print(4)
15
16
                    raise AttributeError
                except:
17
                    print(5)
18
                    pass
19
                print(6)
20
21
                raise
            except TypeError:
22
                print(7)
23
                pass
24
25
            print(8)
        print(9)
26
27
28
29
30
31
32
        # This should raise original ValueError, not the most recently occurred AttributeError
        raise

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