Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Andrew Svetlov
Thanks for the elaboration! On Wed, Dec 26, 2012 at 6:42 PM, Antoine Pitrou wrote: > On Wed, 26 Dec 2012 13:37:13 +0200 > Andrew Svetlov wrote: >> > >> > As Serhiy's example shows, this mapping of error numbers to subclasses >> > is implemented directly in OSError.__new__. We did this so that co

Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Antoine Pitrou
On Wed, 26 Dec 2012 13:37:13 +0200 Andrew Svetlov 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 l

Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Serhiy Storchaka
It sould be in Python-Ideas: add keyword argument support for OSError and subclasses with suitable default values. I.e. >>> OSError(errno=errno.ENOENT) FileNotFoundError(2, 'No such file or directory') >>> FileNotFoundError(filename='qwerty') FileNotFoundError(2, 'No such file or directory') >>>

Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Andrew Svetlov
On Wed, Dec 26, 2012 at 12:16 PM, Nick Coghlan wrote: > On Wed, Dec 26, 2012 at 6:50 PM, Serhiy Storchaka wrote: >> On 25.12.12 23:55, Andrew Svetlov wrote: >>> >>> Currently we have exception tree of classes inherited from OSError >>> When we use C API we can call PyErr_SetFromErrno and >>> PyEr

Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Nick Coghlan
On Wed, Dec 26, 2012 at 6:50 PM, Serhiy Storchaka wrote: > On 25.12.12 23:55, Andrew Svetlov wrote: >> >> Currently we have exception tree of classes inherited from OSError >> When we use C API we can call PyErr_SetFromErrno and >> PyErr_SetFromErrnoWithFilename[Object] functions. >> This ones rai

Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-26 Thread Serhiy Storchaka
On 25.12.12 23:55, Andrew Svetlov wrote: Currently we have exception tree of classes inherited from OSError When we use C API we can call PyErr_SetFromErrno and PyErr_SetFromErrnoWithFilename[Object] functions. This ones raise concrete exception class (FileNotFoundError for example) looking on im

Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-25 Thread Andrew Svetlov
static method is better than new builtin function, agree. On Wed, Dec 26, 2012 at 12:03 AM, Benjamin Peterson wrote: > 2012/12/25 Andrew Svetlov : >> Currently we have exception tree of classes inherited from OSError >> When we use C API we can call PyErr_SetFromErrno and >> PyErr_SetFromErrnoWit

Re: [Python-Dev] Raising OSError concrete classes from errno code

2012-12-25 Thread Benjamin Peterson
2012/12/25 Andrew Svetlov : > Currently we have exception tree of classes inherited from OSError > When we use C API we can call PyErr_SetFromErrno and > PyErr_SetFromErrnoWithFilename[Object] functions. > This ones raise concrete exception class (FileNotFoundError for > example) looking on implici