bpo-45562: Print tokenizer debug messages to stderr (GH-29250) · python/cpython@10bbd41

@@ -1047,9 +1047,9 @@ tok_nextc(struct tok_state *tok)

10471047

}

10481048

#if defined(Py_DEBUG)

10491049

if (Py_DebugFlag) {

1050-

printf("line[%d] = ", tok->lineno);

1050+

fprintf(stderr, "line[%d] = ", tok->lineno);

10511051

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

1052-

printf(" tok->done = %d\n", tok->done);

1052+

fprintf(stderr, " tok->done = %d\n", tok->done);

10531053

}

10541054

#endif

10551055

if (!rc) {

@@ -2127,8 +2127,8 @@ _PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)

21272127

void

21282128

tok_dump(int type, char *start, char *end)

21292129

{

2130-

printf("%s", _PyParser_TokenNames[type]);

2130+

fprintf(stderr, "%s", _PyParser_TokenNames[type]);

21312131

if (type == NAME || type == NUMBER || type == STRING || type == OP)

2132-

printf("(%.*s)", (int)(end - start), start);

2132+

fprintf(stderr, "(%.*s)", (int)(end - start), start);

21332133

}

21342134

#endif // Py_DEBUG