Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-145275: add -X pathconfig_warnings and PYTHON_PATHCONFIG_WARNINGS#145277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
FFY00 merged 3 commits intopython:mainfromFFY00:gh-145275
Mar 2, 2026
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletionsDoc/using/cmdline.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -687,6 +687,13 @@ Miscellaneous options

.. 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
Expand DownExpand Up@@ -1350,6 +1357,14 @@ conflict.

.. 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
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
Added the :option:`-X pathconfig_warnings<-X>` and
:envvar:`PYTHON_PATHCONFIG_WARNINGS` options, allowing to disable warnings
from :ref:`sys-path-init`.
34 changes: 34 additions & 0 deletionsPython/initconfig.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -357,6 +357,9 @@ The following implementation-specific options are available:\n\
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\
Expand DownExpand Up@@ -2350,6 +2353,32 @@ config_init_lazy_imports(PyConfig *config)
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)
{
Expand DownExpand Up@@ -2446,6 +2475,11 @@ config_read_complex_options(PyConfig *config)
return status;
}

status = config_init_pathconfig_warnings(config);
if (_PyStatus_EXCEPTION(status)) {
return status;
}

return _PyStatus_OK();
}

Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp