.. versionadded:: 3.14
+ * :samp:`-X pathconfig_warnings={0,1}` if true (``1``) then
+ :ref:`sys-path-init` is allowed to log warnings into stderr.
+ If false (``0``) suppress these warnings. Set to true by default.
+ See also :envvar:`PYTHON_PATHCONFIG_WARNINGS`.
+
+ .. versionadded:: next
+
* :samp:`-X tlbc={0,1}` enables (1, the default) or disables (0) thread-local
bytecode in builds configured with :option:`--disable-gil`. When disabled,
this also disables the specializing interpreter. See also
.. versionadded:: 3.14
+.. envvar:: PYTHON_PATHCONFIG_WARNINGS
+
+ If true (``1``) then :ref:`sys-path-init` is allowed to log warnings into
+ stderr. If false (``0``) suppress these warnings. Set to true by default.
+ See also :option:`-X pathconfig_warnings<-X>`.
+
+ .. versionadded:: next
+
.. envvar:: PYTHON_JIT
On builds where experimental just-in-time compilation is available, this
use module globals, which is not concurrent-safe; set to true for\n\
free-threaded builds and false otherwise; also\n\
PYTHON_CONTEXT_AWARE_WARNINGS\n\
+-X pathconfig_warnings=[0|1]: if true (1) then path configuration is allowed\n\
+ to log warnings into stderr; if false (0) suppress these warnings;\n\
+ set to true by default; also PYTHON_PATHCONFIG_WARNINGS\n\
-X tracemalloc[=N]: trace Python memory allocations; N sets a traceback limit\n \
of N frames (default: 1); also PYTHONTRACEMALLOC=N\n\
-X utf8[=0|1]: enable (1) or disable (0) UTF-8 mode; also PYTHONUTF8\n\
return _PyStatus_OK();
}
+static PyStatus
+config_init_pathconfig_warnings(PyConfig *config)
+{
+ const char *env = config_get_env(config, "PYTHON_PATHCONFIG_WARNINGS");
+ if (env) {
+ int enabled;
+ if (_Py_str_to_int(env, &enabled) < 0 || (enabled < 0) || (enabled > 1)) {
+ return _PyStatus_ERR(
+ "PYTHON_PATHCONFIG_WARNINGS=N: N is missing or invalid");
+ }
+ config->pathconfig_warnings = enabled;
+ }
+
+ const wchar_t *xoption = config_get_xoption(config, L"pathconfig_warnings");
+ if (xoption) {
+ int enabled;
+ const wchar_t *sep = wcschr(xoption, L'=');
+ if (!sep || (config_wstr_to_int(sep + 1, &enabled) < 0) || (enabled < 0) || (enabled > 1)) {
+ return _PyStatus_ERR(
+ "-X pathconfig_warnings=n: n is missing or invalid");
+ }
+ config->pathconfig_warnings = enabled;
+ }
+ return _PyStatus_OK();
+}
+
static PyStatus
config_read_complex_options(PyConfig *config)
{
return status;
}
+ status = config_init_pathconfig_warnings(config);
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
+ }
+
return _PyStatus_OK();
}