mirror of
https://github.com/python/cpython.git
synced 2025-10-16 19:57:59 +00:00
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.
This commit is contained in:
parent
f9169ce6b4
commit
6b4be195cd
19 changed files with 2221 additions and 2006 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue