summaryrefslogtreecommitdiffstats
path: root/Include/internal
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-11-12 14:14:13 (GMT)
committerGitHub <noreply@github.com>2020-11-12 14:14:13 (GMT)
commitef75a625cdf8377d687a04948b4db9bc1917bf19 (patch)
treef9a979741790c9647b53e3f7c8f2c5fd66b6e56a /Include/internal
parentd19fa7a337d829e3dab3e9f919f5dcf09cf6f6ba (diff)
downloadcpython-ef75a625cdf8377d687a04948b4db9bc1917bf19.zip
cpython-ef75a625cdf8377d687a04948b4db9bc1917bf19.tar.gz
cpython-ef75a625cdf8377d687a04948b4db9bc1917bf19.tar.bz2
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.
Diffstat (limited to 'Include/internal')
-rw-r--r--Include/internal/pycore_interp.h6
-rw-r--r--Include/internal/pycore_pylifecycle.h1
-rw-r--r--Include/internal/pycore_warnings.h2
3 files changed, 6 insertions, 3 deletions
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 4b67a86..184878c 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -190,10 +190,14 @@ struct _is {
struct _ceval_state ceval;
struct _gc_runtime_state gc;
+ // sys.modules dictionary
PyObject *modules;
PyObject *modules_by_index;
+ // Dictionary of the sys module
PyObject *sysdict;
+ // Dictionary of the builtins module
PyObject *builtins;
+ // importlib module
PyObject *importlib;
/* Used in Modules/_threadmodule.c. */
@@ -218,7 +222,7 @@ struct _is {
PyObject *builtins_copy;
PyObject *import_func;
- /* Initialized to PyEval_EvalFrameDefault(). */
+ // Initialized to _PyEval_EvalFrameDefault().
_PyFrameEvalFunction eval_frame;
Py_ssize_t co_extra_user_count;
diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h
index 606252b..e748112 100644
--- a/Include/internal/pycore_pylifecycle.h
+++ b/Include/internal/pycore_pylifecycle.h
@@ -48,7 +48,6 @@ extern int _PySys_UpdateConfig(PyThreadState *tstate);
extern PyStatus _PyExc_Init(PyThreadState *tstate);
extern PyStatus _PyErr_Init(void);
extern PyStatus _PyBuiltins_AddExceptions(PyObject * bltinmod);
-extern PyStatus _PyImportHooks_Init(PyThreadState *tstate);
extern int _PyFloat_Init(void);
extern PyStatus _Py_HashRandomization_Init(const PyConfig *);
diff --git a/Include/internal/pycore_warnings.h b/Include/internal/pycore_warnings.h
index cafe305..2a473b8 100644
--- a/Include/internal/pycore_warnings.h
+++ b/Include/internal/pycore_warnings.h
@@ -17,7 +17,7 @@ struct _warnings_runtime_state {
long filters_version;
};
-extern PyStatus _PyWarnings_InitState(PyThreadState *tstate);
+extern int _PyWarnings_InitState(PyThreadState *tstate);
#ifdef __cplusplus
}