[Python-Dev] Raising OSError concrete classes from errno code
Antoine Pitrou
solipsis at pitrou.net
Wed Dec 26 17:42:02 CET 2012
More information about the Python-Dev mailing list
Wed Dec 26 17:42:02 CET 2012
- Previous message: [Python-Dev] Raising OSError concrete classes from errno code
- Next message: [Python-Dev] Raising OSError concrete classes from errno code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 26 Dec 2012 13:37:13 +0200 Andrew Svetlov <andrew.svetlov at gmail.com> wrote: > > > > As Serhiy's example shows, this mapping of error numbers to subclasses > > is implemented directly in OSError.__new__. We did this so that code > > could catch the new exceptions, even when dealing with old code that > > raises the legacy exception types. > > > Sorry. > Looks like OSError.__new__ requires at least two arguments for > executing subclass search mechanism: > > >>> OSError(errno.ENOENT) > OSError(2,) > >>> OSError(errno.ENOENT, 'error msg') > FileNotFoundError(2, 'error msg') Indeed, it does. I did this for consistency, because calling OSError with only one argument doesn't set the "errno" attribute at all: >>> e = OSError(5) >>> e.errno >>> Regards Antoine.
- Previous message: [Python-Dev] Raising OSError concrete classes from errno code
- Next message: [Python-Dev] Raising OSError concrete classes from errno code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list