summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-12-19 10:35:58 (GMT)
committerGitHub <noreply@github.com>2017-12-19 10:35:58 (GMT)
commit5d8624647d0b8ccb22b17b9e819a8e0c3fb4fe4a (patch)
treeb83a730b4c1711f9d50bf0477f552a714160cf55 /Python/pylifecycle.c
parent21be85f52030b828679ffb9c8cddb5ac48946a30 (diff)
downloadcpython-5d8624647d0b8ccb22b17b9e819a8e0c3fb4fe4a.zip
cpython-5d8624647d0b8ccb22b17b9e819a8e0c3fb4fe4a.tar.gz
cpython-5d8624647d0b8ccb22b17b9e819a8e0c3fb4fe4a.tar.bz2
bpo-32030: Fix compiler warnings (#4921)
Fix compiler warnings in Py_FinalizeEx(): only define variables if they are needed, add #ifdef. Other cleanup changes: * _PyWarnings_InitWithConfig() is no more needed: call _PyWarnings_Init() instead. * Inline pymain_init_main_interpreter() in its caller. This subfunction is no more justifed.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 6500995..678fbb6 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -737,7 +737,7 @@ _Py_InitializeCore(const _PyCoreConfig *core_config)
}
/* Initialize _warnings. */
- if (_PyWarnings_InitWithConfig(&interp->core_config) == NULL) {
+ if (_PyWarnings_Init() == NULL) {
return _Py_INIT_ERR("can't initialize warnings");
}
@@ -847,7 +847,9 @@ _Py_InitializeMainInterpreter(const _PyMainInterpreterConfig *config)
}
/* Initialize warnings. */
- if (PySys_HasWarnOptions()) {
+ if (interp->config.warnoptions != NULL &&
+ PyList_Size(interp->config.warnoptions) > 0)
+ {
PyObject *warnings_module = PyImport_ImportModule("warnings");
if (warnings_module == NULL) {
fprintf(stderr, "'import warnings' failed; traceback:\n");
@@ -1021,9 +1023,15 @@ Py_FinalizeEx(void)
/* Copy the core config, PyInterpreterState_Delete() free
the core config memory */
+#ifdef Py_REF_DEBUG
int show_ref_count = interp->core_config.show_ref_count;
+#endif
+#ifdef Py_TRACE_REFS
int dump_refs = interp->core_config.dump_refs;
+#endif
+#ifdef WITH_PYMALLOC
int malloc_stats = interp->core_config.malloc_stats;
+#endif
/* Remaining threads (e.g. daemon threads) will automatically exit
after taking the GIL (in PyEval_RestoreThread()). */