Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python -d creates lots of tokenizer messages #89725

Closed
malemburg opened this issue Oct 21, 2021 · 15 comments
Closed

python -d creates lots of tokenizer messages #89725

malemburg opened this issue Oct 21, 2021 · 15 comments
Labels
3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@malemburg
Copy link
Member

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']

    @malemburg
    Copy link
    Member Author

    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 ?

    @malemburg malemburg added 3.10 only security fixes labels Oct 21, 2021
    @malemburg
    Copy link
    Member Author

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

    @malemburg malemburg added interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Oct 21, 2021
    @pablogsal
    Copy link
    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

    @miss-islington
    Copy link
    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

    @malemburg
    Copy link
    Member Author

    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.

    @pablogsal
    Copy link
    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

    @pablogsal
    Copy link
    Member

    Thanks you for the catch!

    @malemburg
    Copy link
    Member Author

    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.

    @pablogsal
    Copy link
    Member

    Yeah, let me fix that in another PR

    @miss-islington
    Copy link
    Contributor

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

    @pablogsal
    Copy link
    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

    @malemburg
    Copy link
    Member Author

    Hi Pablo,

    I think you missed one instance:

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

    Cheers

    @pablogsal
    Copy link
    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

    @malemburg
    Copy link
    Member Author

    Thanks, Pablo :-)

    @miss-islington
    Copy link
    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants