[New-bugs-announce] [issue42632] Reassgining ZeroDivisionError will lead to bug in Except clause
Xinmeng Xia
report at bugs.python.org
Mon Dec 14 01:02:52 EST 2020
New submission from Xinmeng Xia <xiaxm at smail.nju.edu.cn>:
Running the following program:
==============================
def foo():
try:
1/0
except ZeroDivisionError as e:
ZeroDivisionError = 1
foo()
==============================
The expected output should be nothing. ZeroDivisionError is caught and then reassignment is executed. However, running this program in Python3.10 will lead to the following error:
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/error/1.py", line 5, in foo
1/0
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xxm/Desktop/nameChanging/error/1.py", line 8, in <module>
foo()
File "/home/xxm/Desktop/nameChanging/error/1.py", line 6, in foo
except Exception as e:
UnboundLocalError: local variable 'Exception' referenced before assignment
----------
components: Interpreter Core
messages: 382953
nosy: xxm
priority: normal
severity: normal
status: open
title: Reassgining ZeroDivisionError will lead to bug in Except clause
type: compile error
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42632>
_______________________________________
More information about the New-bugs-announce
mailing list