2014-03-29 18:48:21 -04:00
|
|
|
# Reraise not the latest occured exception
|
|
|
|
def f():
|
|
|
|
try:
|
|
|
|
raise ValueError("val", 3)
|
|
|
|
except:
|
|
|
|
try:
|
2014-03-29 20:39:15 -04:00
|
|
|
print(1)
|
2014-03-29 18:48:21 -04:00
|
|
|
raise TypeError
|
|
|
|
except:
|
2014-03-29 20:39:15 -04:00
|
|
|
print(2)
|
2014-03-29 18:48:21 -04:00
|
|
|
try:
|
2014-03-29 20:39:15 -04:00
|
|
|
print(3)
|
2014-03-29 18:48:21 -04:00
|
|
|
try:
|
2014-03-29 20:39:15 -04:00
|
|
|
print(4)
|
2014-03-29 18:48:21 -04:00
|
|
|
raise AttributeError
|
|
|
|
except:
|
2014-03-29 20:39:15 -04:00
|
|
|
print(5)
|
2014-03-29 18:48:21 -04:00
|
|
|
pass
|
2014-03-29 20:39:15 -04:00
|
|
|
print(6)
|
2014-03-29 18:48:21 -04:00
|
|
|
raise
|
|
|
|
except TypeError:
|
2014-03-29 20:39:15 -04:00
|
|
|
print(7)
|
2014-03-29 18:48:21 -04:00
|
|
|
pass
|
2014-03-29 20:39:15 -04:00
|
|
|
print(8)
|
|
|
|
print(9)
|
2014-03-29 18:48:21 -04:00
|
|
|
# This should raise original ValueError, not the most recently occurred AttributeError
|
|
|
|
raise
|
|
|
|
|
|
|
|
try:
|
|
|
|
f()
|
|
|
|
except ValueError as e:
|
|
|
|
print(repr(e))
|