This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author remi.lapeyre
Recipients alanr, remi.lapeyre
Date 2020-03-03.21:24:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583270645.27.0.462786357625.issue39841@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-03-03 21:24:05remi.lapeyresetrecipients: + remi.lapeyre, alanr
2020-03-03 21:24:05remi.lapeyresetmessageid: <1583270645.27.0.462786357625.issue39841@roundup.psfhosted.org>
2020-03-03 21:24:05remi.lapeyrelinkissue39841 messages
2020-03-03 21:24:05remi.lapeyrecreate