Skip to content

PYTHONINSPECT is checked inconsistently #143135

Description

@StanFromIreland

Found when testing PYTHONINSPECT for #143134, when you set PYTHONINSPECT to a "non-empty" string that is 0, it is checked in initconfig.c with _Py_get_env_flag:

_Py_get_env_flag(use_env, &config->inspect, "PYTHONINSPECT");

But then directly with _Py_GetEnv in pymain_repl:

cpython/Modules/main.c

Lines 579 to 581 in fc2f0fe

if (!config->inspect && _Py_GetEnv(config->use_environment, "PYTHONINSPECT")) {
pymain_set_inspect(config, 1);
}

So, you end up in this situation:

$ PYTHONINSPECT=0 ./python -c "import sys; print(sys.flags.inspect)"
0
>>> # We still inspect, even though sys.flags.inspect is not set...

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions