New submission from Xinmeng Xia <xi...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue42632> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com