[Python-ideas] PEP 3151 - Reworking the OS and IO exception hierarchy (again)

M.-A. Lemburg mal at egenix.com
Thu Nov 11 10:09:34 CET 2010

Antoine Pitrou wrote:
> Hello,
> Georg (who manages the 3.2 release) suggested that I push PEP 3151 (*)
> in the hope that it can get in before the 3.2 feature freeze.
> Is there any consensus that PEP 3151 should get in 3.2, or even that it
> should get in at all?  If there's some process issue that I'm missing,
> I'd be glad to know about it.
> (*) http://www.python.org/dev/peps/pep-3151/

In its current state, I don't think it should go in 3.2:

There are a couple of cases where you remove more error classes
which will cause existing code to catch more errors than what
the code was designed for, e.g. catching socket.error will
now also catch all IOErrors, code catching OSErrors will now
also catch IOErrors.

By making the scope of an except clause larger, you alter the
semantics of programs using the more fine-grained hierarchies
in ways which are both difficult to detect and harder to work

Since user exceptions often inherit from the stdlib ones,
the situation propogates to user exceptions as well, so
even finding all the places in the code that must be
reviewed gets difficult.

OTOH, the removal of the more fine-grained classes
doesn't gain us anything, e.g. it's pretty obvious that
the os module raises OSErrors, the socket module socket.errors,
the mmap module mmap.errors and so on.

Please also have a look at http://www.python.org/dev/peps/pep-0348/
since some of the things you raise in your PEP were already discussed
and decided a while back, including whether removal of exceptions
and addition of new, more fine-grained ones

I'm +1 on adding more fine-grained error classes, but don't
see much use in removing existing fine-grained structures.

BTW: Why are you discussing the PEP on python-ideas and not
on python-dev where PEPs normally go for further discussion
after they been assigned a PEP number (see
http://www.python.org/dev/peps/pep-0001/) ?

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Nov 11 2010)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the Python-ideas mailing list