Message341170
| Author |
eryksun |
| Recipients |
Raúl Núñez de Arenas, berker.peksag, eryksun, paul.moore, steve.dower, tim.golden, zach.ware |
| Date |
2019年05月01日.00:12:52 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1556669573.27.0.0349125222422.issue26493@roundup.psfhosted.org> |
| In-reply-to |
| Content |
>> A new issue should be raised to fix the FormatMessage calls in the
>> standard library that mistakenly leave out
>> FORMAT_MESSAGE_IGNORE_INSERTS.
>
> Do you suggest to modify OSError constructor to modify the call to
> FormatMessageW(): don't pass the FORMAT_MESSAGE_IGNORE_INSERTS flag?
> I prefer "%1 is not a valid Win32 application" message than
> "<no description>".
I suggested creating a new issue to fix the calls that omit this flag. I think it's just two modules: Modules/overlapped.c and Modules/_ctypes/callproc.c. If there are more inserts than arguments (i.e. any inserts in our case since we pass no arguments), then FormatMessageW fails and the above modules use a default message. For example:
>>> _overlapped.FormatMessage(193)
'unknown error code 193'
>>> _ctypes.FormatError(193)
'<no description>'
> There is no need to re-raise the exception: the "strerror" attribute
> contains the error message and it can be modified.
I meant that Popen._execute_child would handle the exception by modifying and reraising it. In general for OSError exceptions, we could set `filename` to either `executable`, if it's defined, or else parse it out of the commandline. For ERROR_BAD_EXE_FORMAT (193), we could also change `strerror` to something like "Invalid executable format" instead of "%1 is not a valid Win32 application". This is more consistent with how we append ": {filename}" to the message. |
|