From ef75a625cdf8377d687a04948b4db9bc1917bf19 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 12 Nov 2020 15:14:13 +0100 Subject: bpo-42260: Initialize time and warnings earlier at startup (GH-23249) * Call _PyTime_Init() and _PyWarnings_InitState() earlier during the Python initialization. * Inline _PyImportHooks_Init() into _PySys_InitCore(). * The _warnings initialization function no longer call _PyWarnings_InitState() to prevent resetting filters_version to 0. * _PyWarnings_InitState() now returns an int and no longer clear the state in case of error (it's done anyway at Python exit). * Rework init_importlib(), fix refleaks on errors. --- Python/sysmodule.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 61741f7432..f05b33a9aa 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -2841,6 +2841,11 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict) } } + /* adding sys.path_hooks and sys.path_importer_cache */ + SET_SYS("meta_path", PyList_New(0)); + SET_SYS("path_importer_cache", PyDict_New()); + SET_SYS("path_hooks", PyList_New(0)); + if (_PyErr_Occurred(tstate)) { goto err_occurred; } -- cgit v1.2.1