You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just found out that the reasoning around the try:/except Exception as e: nodes is boggus, here is the relevant part of the documentation:
When an exception has been assigned using as target, it is cleared at the end of the except clause.
This is as if
exceptEasN:
foo
was translated to
exceptEasN:
try:
foofinally:
delN
This means the exception must be assigned to a different name to be able to refer to it after the except clause. Exceptions are cleared because with the traceback attached to them, they form a reference cycle with the stack frame, keeping all locals in that frame alive until the next garbage collection occurs.
Approach changed: I'll consider an ast.Del as an ast.Load (as usual) plus a silent special store which, if reached, is ignored. It seems to blend elegantly in current approach, more about this later :-)
Hello @serge-sans-paille, hope you are well.
I've just found out that the reasoning around the
try:/except Exception as e:
nodes is boggus, here is the relevant part of the documentation:When an exception has been assigned using as target, it is cleared at the end of the except clause.
This is as if
was translated to
This means the exception must be assigned to a different name to be able to refer to it after the except clause. Exceptions are cleared because with the traceback attached to them, they form a reference cycle with the stack frame, keeping all locals in that frame alive until the next garbage collection occurs.
Reference: https://docs.python.org/3/reference/compound_stmts.html#the-try-statement
So a reproducer for this issue is the following code (which directly taken from our test suite):
This should generate an unbound identifier warning for
e
.The text was updated successfully, but these errors were encountered: