Eryk Sun <eryk...@gmail.com> added the comment:

>> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue26493>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to