[New-bugs-announce] [issue26174] Exception alias cause destruction of existing variable

Jan Pokorny report at bugs.python.org
Thu Jan 21 10:48:20 EST 2016


New submission from Jan Pokorny:

Encountered a weird behavior when working with variable with the same name as exception's alias.

Observed behavior:

- In case variable with the same name (e.g. 'e') already exists when any 'except Error as e' block is executed, the 'e' variable is removed after exception handling finishes (NameError: name 'e' is not defined)

- Happens only in Python 3
- Code reproducing the issue included

Expected behavior:

- Variable is kept in its pre-exception state

Proposed solution:

- Store colliding variable into temporary variable, restore it afterwards

----------
components: Interpreter Core
files: schrodinger.py
messages: 258757
nosy: japokorn
priority: normal
severity: normal
status: open
title: Exception alias cause destruction of existing variable
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file41683/schrodinger.py

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


More information about the New-bugs-announce mailing list