Message387874
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 |
|
Date |
User |
Action |
Args |
2021-03-01 15:27:31 | eryksun | set | recipients:
+ eryksun, loewis, terry.reedy, paul.moore, exarkun, amaury.forgeotdarc, ggenellina, vstinner, dstanek, schmir, tim.golden, ezio.melotti, brian.curtin, alfps, nvetoshkin, zach.ware, serhiy.storchaka, steve.dower |
2021-03-01 15:27:31 | eryksun | set | messageid: <1614612451.04.0.954090822562.issue8036@roundup.psfhosted.org> |
2021-03-01 15:27:31 | eryksun | link | issue8036 messages |
2021-03-01 15:27:30 | eryksun | create | |
|