[Python-ideas] PEP-3151 pattern-matching

Antoine Pitrou solipsis at pitrou.net
Thu May 12 19:26:45 CEST 2011


On Fri, 08 Apr 2011 10:59:16 +0200
"M.-A. Lemburg" <mal at egenix.com> wrote:
> > 
> > I think EnvironmentError, WindowsError, VMSError, OSError, mmap.error
> > and select.error should definitely all be merged with IOError, as they
> > aren't used consistently enough to make handling them differently
> > reliable even in current code.
> 
> Their use may be inconsistent in a few places, but those cases
> are still well-defined by the implementation, so code relying
> on that well-defined behavior will break in subtle ways.

Another quirk occurred to me today: select.error doesn't derive from
EnvironmentError, and so it doesn't have the errno attribute (even
though the select module "correctly" instantiates it with a (errno,
message) tuple). Also, its str() is borked:

>>> e = select.error(4, "interrupted")
>>> str(e)
"(4, 'interrupted')"
>>> raise e
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
select.error: (4, 'interrupted')

Regards

Antoine.





More information about the Python-ideas mailing list