[New-bugs-announce] [issue15784] OSError.__str__() should distinguish between errno and winerror
Richard Oudkerk
report at bugs.python.org
Sat Aug 25 20:44:37 CEST 2012
New submission from Richard Oudkerk:
Since WindowsError became an alias of OSError, the error number shown in the stringification of an OSError err can either be a windows error code (err.winerror) or a posix style error number (err.errno), with no way to tell which.
For instance in
>>> os.read(999, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 9] Bad file descriptor
err.errno == EBADF == 9 and err.winerror == None, but in
>>> _winapi.ReadFile(999, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Error 6] The handle is invalid
err.errno == EBADF == 9 and err.winerror == ERROR_INVALID_HANDLE == 6. (winerror gets priority over errno if it exists.)
With the attached patch the second will be shown as
>>> _winapi.ReadFile(999, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [WinError 6] The handle is invalid
^^^
Since this issue only applies to 3.3 and the patch is trivial, it would be nice to get this in before 3.3 is released.
----------
files: winerror.patch
keywords: patch
messages: 169153
nosy: pitrou, sbt
priority: normal
severity: normal
status: open
title: OSError.__str__() should distinguish between errno and winerror
Added file: http://bugs.python.org/file27001/winerror.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15784>
_______________________________________
More information about the New-bugs-announce
mailing list