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 <rep...@bugs.python.org>
<http://bugs.python.org/issue22977>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to