[issue42632] Reassgining ZeroDivisionError will lead to bug in Except clause

2020-12-14 Thread Eric V. Smith
Eric V. Smith added the comment: And thanks, Dennis, for the explanation as to why it's the expected behavior. -- ___ Python tracker ___ __

[issue42632] Reassgining ZeroDivisionError will lead to bug in Except clause

2020-12-14 Thread Eric V. Smith
Eric V. Smith added the comment: This code is working as expected, so I'm closing this. -- nosy: +eric.smith resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker __

[issue42632] Reassgining ZeroDivisionError will lead to bug in Except clause

2020-12-14 Thread Dennis Sweeney
Dennis Sweeney added the comment: This is just how local/nonlocal/global/builtin variables work in Python. When you assign to a name anywhere inside of a function, all occurrences of that name refer by default to a local variable. So the line "ZeroDivisionError = 1" tells the foo() function

[issue42632] Reassgining ZeroDivisionError will lead to bug in Except clause

2020-12-13 Thread Xinmeng Xia
Xinmeng Xia added the comment: Similar bugs exist in other exceptions. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue42632] Reassgining ZeroDivisionError will lead to bug in Except clause

2020-12-13 Thread Xinmeng Xia
New submission from Xinmeng Xia : 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