[Python-Dev] Exception chaining and generator finalisation

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Aug 1 05:25:43 CEST 2010


Nick Coghlan wrote:

> I don't see it as an implementation detail - it's part of the spec of
> generator finalisation in PEP 342

It doesn't seem like something you need to know in this
situation, though. All it tells you is that the finalisation
is happening because the generator is being closed rather
than completing on its own.

I suppose it doesn't do any harm, but it seems untidy to
clutter up the traceback with irrelevant and possibly
confusing information.

> Hit Ctrl-C nowTraceback (most recent call last):
>   File "<stdin>", line 2, in <module>
> KeyboardInterrupt
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "<stdin>", line 4, in <module>
> RuntimeError: Ooops

That's a bit different, because the fact that the program
was terminated by Ctrl-C could be useful information.

-- 
Greg


More information about the Python-Dev mailing list