]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45562: Print tokenizer debug messages to stderr (GH-29250)
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Wed, 27 Oct 2021 21:27:34 +0000 (22:27 +0100)
committerGitHub <noreply@github.com>
Wed, 27 Oct 2021 21:27:34 +0000 (14:27 -0700)
Parser/tokenizer.c

index 705da00463d1a7b402348aca21022e2237e3b1d9..4329cdd226e9c6db7a3ed5aa056bca1d77b67867 100644 (file)
@@ -1047,9 +1047,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) {
@@ -2127,8 +2127,8 @@ _PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
 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  // Py_DEBUG