Rémi Lapeyre <remi.lape...@henki.fr> added the comment: 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. ---------- nosy: +remi.lapeyre _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39841> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com