summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-02 14:02:18 (GMT)
committerGitHub <noreply@github.com>2020-03-02 14:02:18 (GMT)
commit66b7973c1b2e6aa6a2462c6b13971a08cd665af2 (patch)
tree29a6bfce69d2d244c2b307ab274e08a935be9fe5 /Python/pylifecycle.c
parent4482337decdbd0c6e2150346a68b3616bda664aa (diff)
downloadcpython-66b7973c1b2e6aa6a2462c6b13971a08cd665af2.zip
cpython-66b7973c1b2e6aa6a2462c6b13971a08cd665af2.tar.gz
cpython-66b7973c1b2e6aa6a2462c6b13971a08cd665af2.tar.bz2
bpo-39796: Fix _warnings module initialization (GH-18739)
* Add _PyWarnings_InitState() which only initializes the _warnings module state (tstate->interp->warnings) without creating a module object * Py_InitializeFromConfig() now calls _PyWarnings_InitState() instead of _PyWarnings_Init() * Rename also private functions of _warnings.c to avoid confusion between the public C API and the private C API.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index fbeebbd..7fa165b 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -677,8 +677,9 @@ pycore_init_import_warnings(PyThreadState *tstate, PyObject *sysmod)
const PyConfig *config = &tstate->interp->config;
if (_Py_IsMainInterpreter(tstate)) {
/* Initialize _warnings. */
- if (_PyWarnings_Init() == NULL) {
- return _PyStatus_ERR("can't initialize warnings");
+ status = _PyWarnings_InitState(tstate);
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
}
if (config->_install_importlib) {