[issue26237] UnboundLocalError error while handling exception

STINNER Victor report at bugs.python.org
Fri Jan 29 04:42:33 EST 2016


STINNER Victor added the comment:

Yes, it's a deliberate change in the Python language. You have to copy "e" to a different variable:

err = None
try:
  ...
except Exception as exc:
  err = exc
print(err)

----------
nosy: +haypo
resolution:  -> not a bug
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26237>
_______________________________________


More information about the Python-bugs-list mailing list