For
def a():
e = 1
try:
raise RuntimeError('forced error')
except Exception as e:
print(e)
print(e)
a()
In both Python 2 and 3, exception variable e shadows the local variable e, and is not being reported.
In python3, e is unbound after the exception block, and a UnboundLocalError occurs when the local variable e is referenced because it was disappeared.
For
In both Python 2 and 3, exception variable
eshadows the local variablee, and is not being reported.In python3,
eis unbound after the exception block, and aUnboundLocalErroroccurs when the local variableeis referenced because it was disappeared.