mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-36763: _PyInitError always use int for exitcode (GH-13360)
We cannot use "unsigned int" for exitcode on Windows, since Py_Main() and _Py_RunMain() always return an "int". Changes: * _PyPathConfig_ComputeSysPath0() now returns -1 if an exception is raised. * pymain_run_python() no longer uses _PyInitError but display the exception and set exitcode to 1 in case of error. * Fix _Py_RunMain(): return an exitcode rather than calling exit() on pymain_run_python() failure. * _Py_ExitInitError() no longer uses ExitProcess() on Windows, use exit() on all platforms. * _Py_ExitInitError() now fails with a fatal error if 'err' is not an error not an exit.
This commit is contained in:
parent
6e78900282
commit
dbacfc2273
4 changed files with 37 additions and 44 deletions
|
@ -2124,17 +2124,14 @@ Py_FatalError(const char *msg)
|
|||
void _Py_NO_RETURN
|
||||
_Py_ExitInitError(_PyInitError err)
|
||||
{
|
||||
assert(_Py_INIT_FAILED(err));
|
||||
if (_Py_INIT_IS_EXIT(err)) {
|
||||
#ifdef MS_WINDOWS
|
||||
ExitProcess(err.exitcode);
|
||||
#else
|
||||
exit(err.exitcode);
|
||||
#endif
|
||||
}
|
||||
else if (_Py_INIT_IS_ERROR(err)) {
|
||||
fatal_error(err._func, err.err_msg, 1);
|
||||
}
|
||||
else {
|
||||
assert(_Py_INIT_IS_ERROR(err));
|
||||
fatal_error(err._func, err.err_msg, 1);
|
||||
Py_FatalError("_Py_ExitInitError() must not be called on success");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue