Message261268
| Author |
eryksun |
| Recipients |
Raúl Núñez de Arenas, eryksun, paul.moore, steve.dower, tim.golden, zach.ware |
| Date |
2016年03月06日.19:58:45 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1457294325.33.0.938747836746.issue26493@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
When Python creates an exception generically from a Windows error code, it calls WinAPI FormatMessage with the flag FORMAT_MESSAGE_IGNORE_INSERTS. The reason for this is explained in a blog post written by Raymond Chen[1]: "when you are not in control of the message, you had better pass the FORMAT_MESSAGE_IGNORE_INSERTS flag."
[1]: https://blogs.msdn.microsoft.com/oldnewthing/20071128-00/?p=24353
Some extension modules in the code base get this wrong. For example, ctypes.FormatError() doesn't use FORMAT_MESSAGE_IGNORE_INSERTS, so it fails to get the system error message for ERROR_BAD_EXE_FORMAT (193) and just returns its default string "<no description>":
>>> ctypes.FormatError(193)
'<no description>' |
|