diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pathconfig.c | 18 | ||||
-rw-r--r-- | Python/pylifecycle.c | 11 |
2 files changed, 15 insertions, 14 deletions
diff --git a/Python/pathconfig.c b/Python/pathconfig.c index 7fea7c3..2fcb816 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -570,18 +570,17 @@ Py_GetProgramName(void) directory ("-m module" case) which will be prepended to sys.argv: sys.path[0]. - Return 1 if the path is correctly resolved, but *path0_p can be NULL - if the Unicode object fail to be created. + Return 1 if the path is correctly resolved and written into *path0_p. - Return 0 if it fails to resolve the full path (and *path0_p will be NULL). - For example, return 0 if the current working directory has been removed - (bpo-36236) or if argv is empty. + Return 0 if it fails to resolve the full path. For example, return 0 if the + current working directory has been removed (bpo-36236) or if argv is empty. + + Raise an exception and return -1 on error. */ int _PyPathConfig_ComputeSysPath0(const _PyWstrList *argv, PyObject **path0_p) { assert(_PyWstrList_CheckConsistency(argv)); - assert(*path0_p == NULL); if (argv->length == 0) { /* Leave sys.path unchanged if sys.argv is empty */ @@ -697,7 +696,12 @@ _PyPathConfig_ComputeSysPath0(const _PyWstrList *argv, PyObject **path0_p) } #endif /* All others */ - *path0_p = PyUnicode_FromWideChar(path0, n); + PyObject *path0_obj = PyUnicode_FromWideChar(path0, n); + if (path0_obj == NULL) { + return -1; + } + + *path0_p = path0_obj; return 1; } 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 */ |