[Python-Dev] GeneratorExit inheriting from Exception

Barry Warsaw barry at python.org
Sat Mar 18 19:50:13 CET 2006


On Sat, 2006-03-18 at 19:32 +0100, Giovanni Bajo wrote:

> +1 on the general idea, I just don't specifically like that "except:" is the
> "wrong" thing to do: part of the PEP352 idea was that people writing
> "except:" out of ignorance would still not cause their program to intercept
> KeyboardInterrupt, or StopIteration.
> 
> Unless this new proposal also includes changing the meaning of "except:" to
> "except Error". 

It's worth debating.  OT1H, it's a semantic different for Python 2.x
(although +1 on the idea for Py3K).  OTOH, I think people generally want
to just catch errors and not all exceptions.  Going along with that,
maybe the interpreter should do something different when an Exception
that's not an Error reaches the top (e.g. not print a traceback if
KeyboardInterrupt is seen -- we usually just catch that, print
"Interrupted" and exit).

> Also, under this new proposal, we could even remove
> Exception from the builtins namespace in Py3k. It's almost always wrong to
> use it, and if you really really need it, it's spelled exceptions.Exception.

I'm not sure I'd go as far as hiding Exception, since I don't think the
penalty is that great and it makes it easier to document.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 309 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20060318/e487e46d/attachment.pgp 


More information about the Python-Dev mailing list