Message363302
Hi Alan, this is documented at https://docs.python.org/3/reference/compound_stmts.html#the-try-statement:
> When an exception has been assigned using as target, it is cleared at the end of the except clause. This is as if
>
> except E as N:
> foo
>
> was translated to
>
> except E as N:
> try:
> foo
> finally:
> del N
>
This is because the exception keeps a reference to the code frame that would make a cycle with the locals which would not be destroyed until the next garbage collection.
I think you will need to use a different name in the except clause. |
|
Date |
User |
Action |
Args |
2020-03-03 21:24:05 | remi.lapeyre | set | recipients:
+ remi.lapeyre, alanr |
2020-03-03 21:24:05 | remi.lapeyre | set | messageid: <1583270645.27.0.462786357625.issue39841@roundup.psfhosted.org> |
2020-03-03 21:24:05 | remi.lapeyre | link | issue39841 messages |
2020-03-03 21:24:05 | remi.lapeyre | create | |
|