[3.13] gh-143135: Fix sys.flags.inspect when PYTHONINSPECT=0 (GH-143136) (GH-143168)

(cherry picked from commit 3509fa5a12)
This commit is contained in:
Stan Ulbrych 2025-12-25 10:57:20 +00:00 committed by GitHub
parent a9e068f0be
commit e132893cc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -0,0 +1,2 @@
Set :data:`sys.flags.inspect` to ``1`` when :envvar:`PYTHONINSPECT` is ``0``.
Previously, it was set to ``0`` in this case.

View file

@ -1576,7 +1576,9 @@ config_read_env_vars(PyConfig *config)
_Py_get_env_flag(use_env, &config->parser_debug, "PYTHONDEBUG");
_Py_get_env_flag(use_env, &config->verbose, "PYTHONVERBOSE");
_Py_get_env_flag(use_env, &config->optimization_level, "PYTHONOPTIMIZE");
_Py_get_env_flag(use_env, &config->inspect, "PYTHONINSPECT");
if (!config->inspect && _Py_GetEnv(use_env, "PYTHONINSPECT")) {
config->inspect = 1;
}
int dont_write_bytecode = 0;
_Py_get_env_flag(use_env, &dont_write_bytecode, "PYTHONDONTWRITEBYTECODE");