Message288076
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) |
|
Date |
User |
Action |
Args |
2017-02-18 12:46:34 | ncoghlan | set | recipients:
+ ncoghlan, vstinner, rbcollins, ezio.melotti, r.david.murray, michael.foord, docs@python, Vjacheslav.Fyodorov, subho |
2017-02-18 12:46:34 | ncoghlan | set | messageid: <1487421994.07.0.0319850201772.issue23890@psf.upfronthosting.co.za> |
2017-02-18 12:46:33 | ncoghlan | link | issue23890 messages |
2017-02-18 12:46:33 | ncoghlan | create | |
|