summaryrefslogtreecommitdiffstats
path: root/Python/_warnings.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-11-23 09:43:14 (GMT)
committerGitHub <noreply@github.com>2017-11-23 09:43:14 (GMT)
commit1f15111a6e15d52f6b08907576ec61493cd59358 (patch)
treeb1a8fd55a1790e3dfd2026cc238e7344f293af90 /Python/_warnings.c
parente32e79f7d8216b78ac9e61bb1f2eee693108d4ee (diff)
downloadcpython-1f15111a6e15d52f6b08907576ec61493cd59358.zip
cpython-1f15111a6e15d52f6b08907576ec61493cd59358.tar.gz
cpython-1f15111a6e15d52f6b08907576ec61493cd59358.tar.bz2
bpo-32030: Add _PyMainInterpreterConfig.pythonhome (#4513)
* Py_Main() now reads the PYTHONHOME environment variable * Add _Py_GetPythonHomeWithConfig() private function * Add _PyWarnings_InitWithConfig() * init_filters() doesn't get the current core configuration from the current interpreter or Python thread anymore. Pass explicitly the configuration to _PyWarnings_InitWithConfig(). * _Py_InitializeCore() now fails on _PyWarnings_InitWithConfig() failure. * Pass configuration as constant
Diffstat (limited to 'Python/_warnings.c')
-rw-r--r--Python/_warnings.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index d865f0a..36d649f 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -1185,10 +1185,9 @@ create_filter(PyObject *category, const char *action)
}
static PyObject *
-init_filters(void)
+init_filters(const _PyCoreConfig *config)
{
- PyInterpreterState *interp = PyThreadState_GET()->interp;
- int dev_mode = interp->core_config.dev_mode;
+ int dev_mode = config->dev_mode;
Py_ssize_t count = 2;
if (dev_mode) {
@@ -1264,8 +1263,8 @@ static struct PyModuleDef warningsmodule = {
};
-PyMODINIT_FUNC
-_PyWarnings_Init(void)
+PyObject*
+_PyWarnings_InitWithConfig(const _PyCoreConfig *config)
{
PyObject *m;
@@ -1274,7 +1273,7 @@ _PyWarnings_Init(void)
return NULL;
if (_PyRuntime.warnings.filters == NULL) {
- _PyRuntime.warnings.filters = init_filters();
+ _PyRuntime.warnings.filters = init_filters(config);
if (_PyRuntime.warnings.filters == NULL)
return NULL;
}
@@ -1305,3 +1304,12 @@ _PyWarnings_Init(void)
_PyRuntime.warnings.filters_version = 0;
return m;
}
+
+
+PyMODINIT_FUNC
+_PyWarnings_Init(void)
+{
+ PyInterpreterState *interp = PyThreadState_GET()->interp;
+ const _PyCoreConfig *config = &interp->core_config;
+ return _PyWarnings_InitWithConfig(config);
+}