[issue8130] except-as in Py3 eats variables

2010-03-13 Thread Florent Xicluna
Florent Xicluna added the comment: See also #4617, with some patch. -- nosy: +flox superseder: -> SyntaxError when free variable name is also an exception target ___ Python tracker

[issue8130] except-as in Py3 eats variables

2010-03-13 Thread Ezio Melotti
Ezio Melotti added the comment: In this case I don't see much difference between deleting a variable or assigning it to something else. This code works on both Python 2 and 3: >>> e = 'test' >>> try: pass# no errors raised here ... except Exception as e: pass # this is not

[issue8130] except-as in Py3 eats variables

2010-03-12 Thread Stefan Behnel
Stefan Behnel added the comment: I knew that the variable was supposed to go out of scope when leaving the except block, but I wasn't aware that this was supposed to be done using (the equivalent of) a 'del'. Were the side-effects of deleting variables defined outside of the try-except consid

[issue8130] except-as in Py3 eats variables

2010-03-12 Thread Ezio Melotti
Ezio Melotti 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() >

[issue8130] except-as in Py3 eats variables

2010-03-12 Thread Stefan Behnel
New submission from Stefan Behnel : Python 3.2a0 (py3k:78205M, Feb 16 2010, 17:32:08) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> e = None [50279 refs] >>> e [50279 refs] >>> try: raise ValueError ... except ValueError as e: pass ... [50277 ref