[issue22977] Unformatted “Windows Error 0x%X” exception message
eryksun
report at bugs.python.org
Tue Dec 2 20:46:05 CET 2014
eryksun added the comment:
This also affects SEH-related exceptions raised by ctypes. For example, VC++ uses exception code 0xE06D7363 (i.e. b'\xe0msc'), so unhandled VC++ exceptions leak into Python like this:
>>> ctypes.windll.kernel32.RaiseException(0xe06d7363, 0, 0, None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [WinError -529697949] Windows Error 0x%X
The ctypes SEH handler defaults to calling PyErr_SetFromWindowsErr(code). Since this isn't actually a Windows error code, Win32 FormatMessageW fails. Then Python uses the following default: PyUnicode_FromFormat("Windows Error 0x%X", err).
Normally (i.e. not under Wine) the OP's error number formats correctly:
>>> ctypes.windll.kernel32.RaiseException(10054, 0, 0, None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
PyErr_SetExcFromWindowsErrWithFilenameObjects
https://hg.python.org/cpython/file/ab2c023a9432/Python/errors.c#l553
PyErr_SetFromErrnoWithFilenameObjects
https://hg.python.org/cpython/file/ab2c023a9432/Python/errors.c#l416
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22977>
_______________________________________
More information about the Python-bugs-list
mailing list