]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45562: Print tokenizer debug messages to stderr (GH-29250) (GH-29252)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 27 Oct 2021 21:45:43 +0000 (14:45 -0700)
committerGitHub <noreply@github.com>
Wed, 27 Oct 2021 21:45:43 +0000 (22:45 +0100)
(cherry picked from commit 10bbd41ba8c88bc102df108a4e0444abc7c5ea43)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Parser/tokenizer.c

index cd348487e0fd5f870c79be874821240d3b65b970..6563cdfd7cc607857933f11666ec7b51304ea77e 100644 (file)
@@ -1046,9 +1046,9 @@ tok_nextc(struct tok_state *tok)
         }
 #if defined(Py_DEBUG)
         if (Py_DebugFlag) {
-            printf("line[%d] = ", tok->lineno);
+            fprintf(stderr, "line[%d] = ", tok->lineno);
             print_escape(stdout, tok->cur, tok->inp - tok->cur);
-            printf("  tok->done = %d\n", tok->done);
+            fprintf(stderr, "  tok->done = %d\n", tok->done);
         }
 #endif
         if (!rc) {
@@ -2132,9 +2132,9 @@ PyTokenizer_FindEncoding(int fd)
 void
 tok_dump(int type, char *start, char *end)
 {
-    printf("%s", _PyParser_TokenNames[type]);
+    fprintf(stderr, "%s", _PyParser_TokenNames[type]);
     if (type == NAME || type == NUMBER || type == STRING || type == OP)
-        printf("(%.*s)", (int)(end - start), start);
+        fprintf(stderr, "(%.*s)", (int)(end - start), start);
 }
 
 #endif