[issue8130] except-as in Py3 eats variables
Ezio Melotti
report at bugs.python.org
Sat Mar 13 08:39:30 CET 2010
Ezio Melotti <ezio.melotti at gmail.com> added the comment:
This is a not a bug and it's documented: http://docs.python.org/py3k/reference/compound_stmts.html#the-try-statement
The solution is to assign the value to another variable:
>>> try: raise ValueError
... except ValueError as e: exc = e
...
>>> exc
ValueError()
>>> e
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'e' is not defined
----------
nosy: +ezio.melotti
priority: -> normal
resolution: -> invalid
stage: -> committed/rejected
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8130>
_______________________________________
More information about the Python-bugs-list
mailing list