Skip to content

Commit f13229c

Browse files
StanFromIrelandmiss-islington
authored andcommitted
gh-143135: Fix sys.flags.inspect when PYTHONINSPECT=0 (GH-143136)
(cherry picked from commit 3509fa5) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent b921374 commit f13229c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Set :data:`sys.flags.inspect` to ``1`` when :envvar:`PYTHONINSPECT` is ``0``.
2+
Previously, it was set to ``0`` in this case.

Python/initconfig.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1845,7 +1845,9 @@ config_read_env_vars(PyConfig *config)
18451845
_Py_get_env_flag(use_env, &config->parser_debug, "PYTHONDEBUG");
18461846
_Py_get_env_flag(use_env, &config->verbose, "PYTHONVERBOSE");
18471847
_Py_get_env_flag(use_env, &config->optimization_level, "PYTHONOPTIMIZE");
1848-
_Py_get_env_flag(use_env, &config->inspect, "PYTHONINSPECT");
1848+
if (!config->inspect && _Py_GetEnv(use_env, "PYTHONINSPECT")) {
1849+
config->inspect = 1;
1850+
}
18491851

18501852
int dont_write_bytecode = 0;
18511853
_Py_get_env_flag(use_env, &dont_write_bytecode, "PYTHONDONTWRITEBYTECODE");

0 commit comments

Comments
 (0)