Skip to content

PYTHON_LLTRACE/PYTHON_OPT_DEBUG only reads first character of environment variable #148638

Open

Description

@StepfenShawn

Feature or enhancement

Proposal:

The PYTHON_LLTRACE and PYTHON_OPT_DEBUG environment variables are currently parsed by only reading the first character:

lltrace = *python_lltrace - '0';  // '10' becomes 1

This means values like PYTHON_LLTRACE=10 are interpreted as 1 instead of 10.

PR: #148636

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. Fidget-Spinner commented on Apr 16, 2026

    @Fidget-Spinner
    Member

    I think we should just remove the TODO comments. There's no need to parse them anyways, these values never exceed 5.

  2. StepfenShawn commented on Apr 16, 2026

    @StepfenShawn
    ContributorAuthor

    The code currently checks if (lltrace >= 5) in multiple places (ceval.h, ceval_macros.h, bytecodes.c), which explicitly handles values of 5 and above. For example:

    // ceval.h:304-306
    if (lltrace >= 5) {
        lltrace_resume_frame(frame);
    }

    My thought is: While today's levels only go up to 5, the >= comparison itself signals that higher values are semantically valid and may be used for even more verbose tracing in the future🤔?

  3. Fidget-Spinner commented on Apr 16, 2026

    @Fidget-Spinner
    Member

    The env var is used for internal development purposes. I really hope we dont exceed 9 levels.

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-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions