Message 162055 - Python tracker (original) (raw)
Ok, so turns out this was just a stupid bug: we set the context attr only if an exception is raised, but not when an exception has been previously 'cleared'. so the context is filled (by python) with the last exception raised which is the outer one. deleting the 'if last context is an exception' solved it.
This is how I understood it: the exception's context is set when it's raised and not in its except clause, meaning there is no way the outer with is mutating our inner exceptions. using pdb I saw the outer exception being explicitly set.