diff options
Diffstat (limited to 'Programs')
-rw-r--r-- | Programs/_freeze_importlib.c | 5 | ||||
-rw-r--r-- | Programs/python.c | 14 |
2 files changed, 15 insertions, 4 deletions
diff --git a/Programs/_freeze_importlib.c b/Programs/_freeze_importlib.c index 1069966a18..b8b630cfed 100644 --- a/Programs/_freeze_importlib.c +++ b/Programs/_freeze_importlib.c @@ -81,7 +81,10 @@ main(int argc, char *argv[]) Py_SetProgramName(L"./_freeze_importlib"); /* Don't install importlib, since it could execute outdated bytecode. */ - _Py_InitializeEx_Private(1, 0); + _PyInitError err = _Py_InitializeEx_Private(1, 0); + if (_Py_INIT_FAILED(err)) { + _Py_FatalInitError(err); + } if (strstr(inpath, "_external") != NULL) { is_bootstrap = 0; diff --git a/Programs/python.c b/Programs/python.c index 270a11babb..707e38f257 100644 --- a/Programs/python.c +++ b/Programs/python.c @@ -1,6 +1,7 @@ /* Minimal main program -- everything is loaded from the library */ #include "Python.h" +#include "internal/pystate.h" #include <locale.h> #ifdef __FreeBSD__ @@ -22,9 +23,16 @@ main(int argc, char **argv) wchar_t **argv_copy; /* We need a second copy, as Python might modify the first one. */ wchar_t **argv_copy2; - int i, res; + int i, status; char *oldloc; + _PyInitError err = _PyRuntime_Initialize(); + if (_Py_INIT_FAILED(err)) { + fprintf(stderr, "Fatal Python error: %s\n", err.msg); + fflush(stderr); + exit(1); + } + /* Force malloc() allocator to bootstrap Python */ #ifdef Py_DEBUG (void)_PyMem_SetupAllocators("malloc_debug"); @@ -88,7 +96,7 @@ main(int argc, char **argv) setlocale(LC_ALL, oldloc); PyMem_RawFree(oldloc); - res = Py_Main(argc, argv_copy); + status = Py_Main(argc, argv_copy); /* Force again malloc() allocator to release memory blocks allocated before Py_Main() */ @@ -103,6 +111,6 @@ main(int argc, char **argv) } PyMem_RawFree(argv_copy); PyMem_RawFree(argv_copy2); - return res; + return status; } #endif |