diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-05-16 14:39:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-16 14:39:26 (GMT) |
commit | dbacfc227381fbc7b3c886ea0bd7806ab3dc62c2 (patch) | |
tree | 7669139306b262719531d501001f417fb113f17b /Python/pylifecycle.c | |
parent | 6e7890028213b30939327e7cf885bf097fc14472 (diff) | |
download | cpython-dbacfc227381fbc7b3c886ea0bd7806ab3dc62c2.zip cpython-dbacfc227381fbc7b3c886ea0bd7806ab3dc62c2.tar.gz cpython-dbacfc227381fbc7b3c886ea0bd7806ab3dc62c2.tar.bz2 |
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.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 4e74e0b..a173eb3 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -2124,18 +2124,15 @@ 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 { - assert(_Py_INIT_IS_ERROR(err)); + else if (_Py_INIT_IS_ERROR(err)) { fatal_error(err._func, err.err_msg, 1); } + else { + Py_FatalError("_Py_ExitInitError() must not be called on success"); + } } /* Clean up and exit */ |