try... except with unknown error types

Stefan Krah stefan-usenet at bytereef.org
Fri Sep 9 23:41:18 CEST 2011


Chris Torek <nospam at torek.net> wrote:
> (I have also never been sure whether something is going to raise
> an IOError or an OSError for various OS-related read or write
> operation failures -- such as exceeding a resource limit, for
> instance -- so most places that do I/O operations on OS files, I
> catch both.  Still, it sure would be nice to have a static analysis
> tool that could answer questions about potential exceptions. :-) )

There is an effort to fix this:

http://www.python.org/dev/peps/pep-3151/


And an implementation ...

http://hg.python.org/features/pep-3151/


... together with a feature request:

http://bugs.python.org/issue12555


I think the whole concept makes a lot of sense and is really worth
taking a look at.


Stefan Krah





More information about the Python-list mailing list