[Python-Dev] PEP 348: Exception Reorganization for Python 3.0

Raymond Hettinger raymond.hettinger at verizon.net
Sat Aug 6 18:12:35 CEST 2005

[Nick Coghlan]
> As others have pointed out, GeneratorExit and StopIteration should
> reach
> the job execution loop - if they do, there's a bug in the job, and
> should
> be caught and logged.

Please read my other, detailed post on this (8/5/2005 4:05pm).  It is a
mistake to bypass control flow exceptions like GeneratorExit and
StopIteration.  Those need to remain under Exception.  Focus on your
core use case of eliminating the common idiom:

   except KeyboardInterrupt:
       pass    # or some handler/logger

In real code, I've never seen the above idiom used with StopIteration.
Read Guido's note and my note.  There are plenty of valid use cases for
a bare except intending to catch almost everything including programming
errors from NameError to StopIteration.  It is a consenting-adults
construct.  Your proposal breaks a major use case for it (preventing
your sales demos from crashing in front of your customers, writing
fault-tolerant programs, etc.)


More information about the Python-Dev mailing list