Skip to content

python -d creates lots of tokenizer messages #89725

Closed

Description

@malemburg
BPO 45562
Nosy @malemburg, @lysnikolaou, @pablogsal, @miss-islington
PRs
  • bpo-45562: Only show debug output from the parser in debug builds #29140
  • [3.10] bpo-45562: Only show debug output from the parser in debug builds (GH-29140) #29149
  • bpo-45562: Print tokenizer debug messages to stderr #29250
  • [3.10] bpo-45562: Print tokenizer debug messages to stderr (GH-29250) #29252
  • bpo-45562: Ensure all tokenizer debug messages are printed to stderr #29270
  • [3.10] bpo-45562: Ensure all tokenizer debug messages are printed to stderr (GH-29270) #29275
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-10-27.21:33:29.126>
    created_at = <Date 2021-10-21.21:54:15.480>
    labels = ['interpreter-core', '3.10']
    title = 'python -d creates lots of tokenizer messages'
    updated_at = <Date 2021-10-29.17:21:23.715>
    user = 'https://github.com/malemburg'

    bugs.python.org fields:

    activity = <Date 2021-10-29.17:21:23.715>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-27.21:33:29.126>
    closer = 'pablogsal'
    components = ['Parser']
    creation = <Date 2021-10-21.21:54:15.480>
    creator = 'lemburg'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45562
    keywords = ['patch']
    message_count = 15.0
    messages = ['404673', '404675', '404689', '404730', '404738', '404743', '404744', '404758', '404773', '405127', '405131', '405176', '405199', '405202', '405325']
    nosy_count = 4.0
    nosy_names = ['lemburg', 'lys.nikolaou', 'pablogsal', 'miss-islington']
    pr_nums = ['29140', '29149', '29250', '29252', '29270', '29275']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue45562'
    versions = ['Python 3.10']

    Activity

    1. malemburg commented on Oct 21, 2021

      @malemburg
      MemberAuthor

      python3.9 -d:

      Python 3.9.7 (default, Oct 21 2021, 20:51:19)
      [GCC 7.5.0] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      Loaded pyinteractive.py.

      >>

      python3.10 -d:

      Python 3.10.0 (default, Oct 21 2021, 23:13:32) [GCC 7.5.0] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      line[1] = "\"\"\" pyinteractive.py\n" tok->done = 10
      line[2] = "\n" tok->done = 10
      line[3] = " This file is executed on interactive startup by Python\n" tok->done = 10
      ...

      (not that in both cases a PYTHONINTERACTIVE script is loaded)

      Is that intended ?

    2. malemburg commented on Oct 21, 2021

      @malemburg
      MemberAuthor

      What's even worse is that those debug lines get written to stdout, not stderr.

    3. pablogsal commented on Oct 21, 2021

      @pablogsal
      Member

      Yeah, those are expected in 3.10, but this should not appear in release versions (only on debug ones).

      Python -d is normally used to debug the parser:

      -d : turn on parser debugging output (for experts only, only works on
      debug builds); also PYTHONDEBUG=x

    4. miss-islington commented on Oct 22, 2021

      @miss-islington
      Contributor

      New changeset 86dfb55 by Pablo Galindo Salgado in branch 'main':
      bpo-45562: Only show debug output from the parser in debug builds (GH-29140)
      86dfb55

    5. malemburg commented on Oct 22, 2021

      @malemburg
      MemberAuthor

      Yes, I know that (at the moment) it's only documented to work in the parser, but since Py_DebugFlag is a general purpose flag, this use could easily be extended to other parts of the interpreter as well, e.g. for parsing the command line or instrumenting the interpreter to collect debug stats.

      In any case, thanks for the quick fix, Pablo.

    6. pablogsal commented on Oct 22, 2021

      @pablogsal
      Member

      New changeset ae78ffd by Miss Islington (bot) in branch '3.10':
      bpo-45562: Only show debug output from the parser in debug builds (GH-29140) (bpo-29149)
      ae78ffd

    7. pablogsal commented on Oct 22, 2021

      @pablogsal
      Member

      Thanks you for the catch!

    8. malemburg commented on Oct 22, 2021

      @malemburg
      MemberAuthor

      I had left a comment on Github about using stderr instead of stdout, to make the output more consistent (other parser error messages go to stderr).

      Note sure whether that's something you still want to change before closing the issue.

    9. pablogsal commented on Oct 22, 2021

      @pablogsal
      Member

      Yeah, let me fix that in another PR

    10. miss-islington commented on Oct 27, 2021

      @miss-islington
      Contributor

      New changeset 10bbd41 by Pablo Galindo Salgado in branch 'main':
      bpo-45562: Print tokenizer debug messages to stderr (GH-29250)
      10bbd41

    11. pablogsal commented on Oct 27, 2021

      @pablogsal
      Member

      New changeset 038f452 by Miss Islington (bot) in branch '3.10':
      bpo-45562: Print tokenizer debug messages to stderr (GH-29250) (GH-29252)
      038f452

    12. malemburg commented on Oct 28, 2021

      @malemburg
      MemberAuthor

      Hi Pablo,

      I think you missed one instance:

      print_escape(stdout, tok->cur, tok->inp - tok->cur);

      Cheers

    13. pablogsal commented on Oct 28, 2021

      @pablogsal
      Member

      New changeset cdc7a58 by Pablo Galindo Salgado in branch 'main':
      bpo-45562: Ensure all tokenizer debug messages are printed to stderr (GH-29270)
      cdc7a58

    14. malemburg commented on Oct 28, 2021

      @malemburg
      MemberAuthor

      Thanks, Pablo :-)

    15. miss-islington commented on Oct 29, 2021

      @miss-islington
      Contributor

      New changeset d8ca47c by Miss Islington (bot) in branch '3.10':
      bpo-45562: Ensure all tokenizer debug messages are printed to stderr (GH-29270)
      d8ca47c

    16. transferred this issue fromon Apr 10, 2022
    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

      3.10 (EOL)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions