[Python-ideas] Add support keyword arguments with suitable defaults for OSError and subclasses

Serhiy Storchaka storchaka at gmail.com
Wed Dec 26 13:31:12 CET 2012


Now OSError constructor does not support keyword arguments. It will be 
good add support for followed keyword arguments: "errno", "strerror", 
"filename".

If "strerror" is not specified, a standard error message corresponding 
to errno is used. If "errno" is not specified for an OSError subclass, 
an errno associated with this subclass is used (if only one errno 
associated).

For backward compatibility perhaps keyword arguments should be 
incompatible with any positional arguments (or at least suitable 
defaults should used only if any keyword argument specified).

Examples:

 >>> OSError(errno=errno.ENOENT)
FileNotFoundError(2, 'No such file or directory')
 >>> FileNotFoundError(filename='qwerty')
FileNotFoundError(2, 'No such file or directory')
 >>> FileNotFoundError(strerr='Bad file')
FileNotFoundError(2, 'Bad file')




More information about the Python-ideas mailing list