Eryk Sun <[email protected]> added the comment:
The internal spawn function in ucrt, common_spawnv(), verifies its parameters
as follows:
_VALIDATE_RETURN(file_name != nullptr, EINVAL, -1);
_VALIDATE_RETURN(file_name[0] != '\0', EINVAL, -1);
_VALIDATE_RETURN(arguments != nullptr, EINVAL, -1);
_VALIDATE_RETURN(arguments[0] != nullptr, EINVAL, -1);
_VALIDATE_RETURN(arguments[0][0] != '\0', EINVAL, -1);
Currently os.spawnv() and os.spawnve() check for and raise ValueError for all
of these cases except the second one, in which file_name is an empty string.
Microsoft doesn't document this case [1]:
These functions validate their parameters. If either cmdname or argv
is a null pointer, or if argv points to null pointer, or argv[0] is
an empty string, the invalid parameter handler is invoked, as
described in Parameter Validation.
In a release build, this case fails with EINVAL. In a debug build, the default
error-reporting settings display a pop message about the invalid argument. The
message box is easy enough to suppress. But for the sake of consistency with
the other cases, os_spawnv_impl in Modules/posixmodule.c should raise a
ValueError if `path` is an empty string. For example:
#ifdef HAVE_WSPAWNV
if (!path->wide[0]) {
PyErr_SetString(PyExc_ValueError,
"spawnv() arg 1 cannot be an empty string");
return NULL;
}
#endif
---
[1]
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/spawnv-wspawnv
----------
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
priority: high -> normal
title: Interpreter crashes on invalid arg to spawnl on Windows -> raise
ValueError for empty `path` in os.spawnv[e]
type: crash -> behavior
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 2.7, Python 3.2, Python
3.3
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue8036>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com