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 ncoghlan
Recipients Vjacheslav.Fyodorov, docs@python, ezio.melotti, michael.foord, ncoghlan, r.david.murray, rbcollins, subho, vstinner
Date 2017-02-18.12:46:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487421994.07.0.0319850201772.issue23890@psf.upfronthosting.co.za>
In-reply-to
Content
As Robert noted, this is a straight up error, where the clear_frames() call and deleting the exception traceback from the saved object aren't enough to drop all references to `callable_obj`.

The trick is that the cleanup code isn't accounting for __cause__ and __context__: it's only clearing and dropping the traceback for the topmost exception in the chain.

In Vjacheslav's example, there are *two* tracebacks to worry about: both the top level one (which is getting cleaned up) and the inner one from exc.__context__ which isn't being touched.

We could likely use a "traceback.clear_all_frames()" helper that walks an exception tree clearing *all* the traceback frames, both on the original exception, and on all the __cause__ and __context__ attributes.

(We can't just clear __cause__ and __context__, since those can be accessed and tested when using the context manager form and the `exception` attribute)
History
Date User Action Args
2017-02-18 12:46:34ncoghlansetrecipients: + ncoghlan, vstinner, rbcollins, ezio.melotti, r.david.murray, michael.foord, docs@python, Vjacheslav.Fyodorov, subho
2017-02-18 12:46:34ncoghlansetmessageid: <1487421994.07.0.0319850201772.issue23890@psf.upfronthosting.co.za>
2017-02-18 12:46:33ncoghlanlinkissue23890 messages
2017-02-18 12:46:33ncoghlancreate