This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: python -d creates lots of tokenizer messages
Type: Stage: resolved
Components: Parser Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lemburg, lys.nikolaou, miss-islington, pablogsal
Priority: normal Keywords: patch

Created on 2021-10-21 21:54 by lemburg, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29140 merged pablogsal, 2021-10-21 22:26
PR 29149 merged miss-islington, 2021-10-22 08:52
PR 29250 merged pablogsal, 2021-10-27 21:03
PR 29252 merged miss-islington, 2021-10-27 21:27
PR 29270 merged pablogsal, 2021-10-28 13:09
PR 29275 merged miss-islington, 2021-10-28 17:06
Messages (15)
msg404673 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2021-10-21 21:54
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 ?
msg404675 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2021-10-21 22:04
What's even worse is that those debug lines get written to stdout, not stderr.
msg404689 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-21 22:23
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
msg404730 - (view) Author: miss-islington (miss-islington) Date: 2021-10-22 08:52
New changeset 86dfb55d2e091cf633dbd7aabcd49d96fb1f9d81 by Pablo Galindo Salgado in branch 'main':
bpo-45562: Only show debug output from the parser in debug builds (GH-29140)
https://github.com/python/cpython/commit/86dfb55d2e091cf633dbd7aabcd49d96fb1f9d81
msg404738 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2021-10-22 09:45
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.
msg404743 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-22 10:14
New changeset ae78ffdc9399802621eabcd1668e44a91ec5f45e by Miss Islington (bot) in branch '3.10':
bpo-45562: Only show debug output from the parser in debug builds (GH-29140) (#29149)
https://github.com/python/cpython/commit/ae78ffdc9399802621eabcd1668e44a91ec5f45e
msg404744 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-22 10:15
Thanks you for the catch!
msg404758 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2021-10-22 12:23
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.
msg404773 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-22 14:31
Yeah, let me fix that in another PR
msg405127 - (view) Author: miss-islington (miss-islington) Date: 2021-10-27 21:27
New changeset 10bbd41ba8c88bc102df108a4e0444abc7c5ea43 by Pablo Galindo Salgado in branch 'main':
bpo-45562: Print tokenizer debug messages to stderr (GH-29250)
https://github.com/python/cpython/commit/10bbd41ba8c88bc102df108a4e0444abc7c5ea43
msg405131 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-27 21:45
New changeset 038f45230892235e806ef227dfd9484b95687823 by Miss Islington (bot) in branch '3.10':
bpo-45562: Print tokenizer debug messages to stderr (GH-29250) (GH-29252)
https://github.com/python/cpython/commit/038f45230892235e806ef227dfd9484b95687823
msg405176 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2021-10-28 10:42
Hi Pablo,

I think you missed one instance:

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

Cheers
msg405199 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-10-28 17:06
New changeset cdc7a5827754bec83970bb052d410d55f85b3fff by Pablo Galindo Salgado in branch 'main':
bpo-45562: Ensure all tokenizer debug messages are printed to stderr (GH-29270)
https://github.com/python/cpython/commit/cdc7a5827754bec83970bb052d410d55f85b3fff
msg405202 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2021-10-28 17:10
Thanks, Pablo :-)
msg405325 - (view) Author: miss-islington (miss-islington) Date: 2021-10-29 17:21
New changeset d8ca47c943c4ad396a9c70aff35bbbf4b1868876 by Miss Islington (bot) in branch '3.10':
bpo-45562: Ensure all tokenizer debug messages are printed to stderr (GH-29270)
https://github.com/python/cpython/commit/d8ca47c943c4ad396a9c70aff35bbbf4b1868876
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89725
2021-10-29 17:21:23miss-islingtonsetmessages: + msg405325
2021-10-28 17:10:34lemburgsetmessages: + msg405202
2021-10-28 17:06:34miss-islingtonsetpull_requests: + pull_request27538
2021-10-28 17:06:24pablogsalsetmessages: + msg405199
2021-10-28 13:09:44pablogsalsetpull_requests: + pull_request27534
2021-10-28 10:42:38lemburgsetmessages: + msg405176
2021-10-27 21:45:51pablogsalsetmessages: + msg405131
2021-10-27 21:33:29pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-10-27 21:27:42miss-islingtonsetpull_requests: + pull_request27516
2021-10-27 21:27:42miss-islingtonsetmessages: + msg405127
2021-10-27 21:03:20pablogsalsetstage: patch review
pull_requests: + pull_request27514
2021-10-22 14:31:26pablogsalsetmessages: + msg404773
2021-10-22 12:23:42lemburgsetmessages: + msg404758
stage: patch review -> (no value)
2021-10-22 10:15:11pablogsalsetmessages: + msg404744
2021-10-22 10:14:52pablogsalsetmessages: + msg404743
2021-10-22 09:45:26lemburgsetmessages: + msg404738
2021-10-22 08:52:32miss-islingtonsetpull_requests: + pull_request27426
2021-10-22 08:52:28miss-islingtonsetnosy: + miss-islington
messages: + msg404730
2021-10-21 22:26:23pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request27416
2021-10-21 22:23:30pablogsalsetmessages: + msg404689
2021-10-21 22:04:23lemburgsetnosy: + pablogsal, lys.nikolaou
components: + Parser
2021-10-21 22:04:00lemburgsetmessages: + msg404675
2021-10-21 21:54:15lemburgcreate