
Antoine Pitrou wrote:
On Fri, 08 Apr 2011 10:59:16 +0200 "M.-A. Lemburg" <mal@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')
Works fine in Python 2.7:
import select e = select.error(4, "intr") e error(4, 'intr') try: ... raise e ... except select.error, x: ... code, text = x ... print code,text ... 4 intr
Note that existing code will not look for an attribute that doesn't exist :-) It'll unwrap the tuple and work from there or use the .args attribute to get at the constructor args. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 12 2011)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
2011-06-20: EuroPython 2011, Florence, Italy 39 days to go ::: 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 http://www.egenix.com/company/contact/