[issue3112] implement PEP 3134 exception reporting
report at bugs.python.org
Sun Jun 22 21:57:52 CEST 2008
Adam Olsen <rhamph at gmail.com> added the comment:
On Sun, Jun 22, 2008 at 1:48 PM, Antoine Pitrou <report at bugs.python.org> wrote:
> Antoine Pitrou <pitrou at free.fr> added the comment:
> Le dimanche 22 juin 2008 à 19:23 +0000, Adam Olsen a écrit :
>> For this behaviour, this is the most natural way to write it.
>> Conceptually, there shouldn't be a cycle
> I agree your example is not far-fetched. How about avoiding cycles for
> implicit chaining, and letting users shoot themselves in the foot with
> explicit recursive chaining if they want? Detection would be cheap
> enough, just a simple loop without any memory allocation.
That's still O(n). I'm not so easily convinced it's cheap enough.
And for that matter, I'm not convinced it's correct. The inner
exception's context becomes clobbered when we modify the outer
exception's traceback. The inner's context should reference the
traceback as it was at that point.
This would all be a lot easier if reraising always created a new
exception. Can you think of a way to skip that only when we can be
sure its safe? Maybe as simple as counting the references to it?
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list