diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2017-05-23 04:36:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-23 04:36:03 (GMT) |
commit | 6b4be195cd8868b76eb6fbe166acc39beee8ce36 (patch) | |
tree | bbab44fad32c576b9eb7e4b83368e200adc33f00 /Python/pylifecycle.c | |
parent | f9169ce6b48c7cc7cc62d9eb5e4ee1ac7066d14b (diff) | |
download | cpython-6b4be195cd8868b76eb6fbe166acc39beee8ce36.zip cpython-6b4be195cd8868b76eb6fbe166acc39beee8ce36.tar.gz cpython-6b4be195cd8868b76eb6fbe166acc39beee8ce36.tar.bz2 |
bpo-22257: Small changes for PEP 432. (#1728)
PEP 432 specifies a number of large changes to interpreter startup code, including exposing a cleaner C-API. The major changes depend on a number of smaller changes. This patch includes all those smaller changes.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 90f8551..03601ea 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -291,6 +291,9 @@ import_init(PyInterpreterState *interp, PyObject *sysmod) /* Install importlib as the implementation of import */ value = PyObject_CallMethod(importlib, "_install", "OO", sysmod, impmod); + if (value != NULL) + value = PyObject_CallMethod(importlib, + "_install_external_importers", ""); if (value == NULL) { PyErr_Print(); Py_FatalError("Py_Initialize: importlib install failed"); @@ -331,8 +334,8 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib) Py_OptimizeFlag = add_flag(Py_OptimizeFlag, p); if ((p = Py_GETENV("PYTHONDONTWRITEBYTECODE")) && *p != '\0') Py_DontWriteBytecodeFlag = add_flag(Py_DontWriteBytecodeFlag, p); - /* The variable is only tested for existence here; _PyRandom_Init will - check its value further. */ + /* The variable is only tested for existence here; + _Py_HashRandomization_Init will check its value further. */ if ((p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0') Py_HashRandomizationFlag = add_flag(Py_HashRandomizationFlag, p); #ifdef MS_WINDOWS @@ -342,7 +345,7 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib) Py_LegacyWindowsStdioFlag = add_flag(Py_LegacyWindowsStdioFlag, p); #endif - _PyRandom_Init(); + _Py_HashRandomization_Init(); _PyInterpreterState_Init(); interp = PyInterpreterState_New(); @@ -402,13 +405,15 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib) /* initialize builtin exceptions */ _PyExc_Init(bimod); - sysmod = _PySys_Init(); + sysmod = _PySys_BeginInit(); if (sysmod == NULL) Py_FatalError("Py_Initialize: can't initialize sys"); interp->sysdict = PyModule_GetDict(sysmod); if (interp->sysdict == NULL) Py_FatalError("Py_Initialize: can't initialize sys dict"); Py_INCREF(interp->sysdict); + if (_PySys_EndInit(interp->sysdict) < 0) + Py_FatalError("Py_Initialize: can't initialize sys"); _PyImport_FixupBuiltin(sysmod, "sys"); PySys_SetPath(Py_GetPath()); PyDict_SetItemString(interp->sysdict, "modules", @@ -694,7 +699,7 @@ Py_FinalizeEx(void) PyDict_Fini(); PySlice_Fini(); _PyGC_Fini(); - _PyRandom_Fini(); + _Py_HashRandomization_Fini(); _PyArg_Fini(); PyAsyncGen_Fini(); |