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

gh-93103: Parser uses PyConfig.parser_debug instead of Py_DebugFlag #93106

Merged
merged 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Parser/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Parser/pegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,9 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags,
p->known_err_token = NULL;
p->level = 0;
p->call_invalid_rules = 0;
#ifdef Py_DEBUG
p->debug = _Py_GetConfig()->parser_debug;
#endif
return p;
}

Expand Down
1 change: 1 addition & 0 deletions Parser/pegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typedef struct {
Token *known_err_token;
int level;
int call_invalid_rules;
int debug;
} Parser;

typedef struct {
Expand Down
5 changes: 4 additions & 1 deletion Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ tok_new(void)
tok->async_def_nl = 0;
tok->interactive_underflow = IUNDERFLOW_NORMAL;
tok->str = NULL;
#ifdef Py_DEBUG
tok->debug = _Py_GetConfig()->parser_debug;
#endif
return tok;
}

Expand Down Expand Up @@ -1021,7 +1024,7 @@ tok_nextc(struct tok_state *tok)
rc = tok_underflow_file(tok);
}
#if defined(Py_DEBUG)
if (Py_DebugFlag) {
if (tok->debug) {
fprintf(stderr, "line[%d] = ", tok->lineno);
print_escape(stderr, tok->cur, tok->inp - tok->cur);
fprintf(stderr, " tok->done = %d\n", tok->done);
Expand Down
3 changes: 3 additions & 0 deletions Parser/tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ struct tok_state {
NEWLINE token after it. */
/* How to proceed when asked for a new token in interactive mode */
enum interactive_underflow_t interactive_underflow;
#ifdef Py_DEBUG
int debug;
#endif
};

extern struct tok_state *_PyTokenizer_FromString(const char *, int);
Expand Down
2 changes: 1 addition & 1 deletion Python/frozenmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Py_FrozenMain(int argc, char **argv)
PyWinFreeze_ExeInit();
#endif

if (Py_VerboseFlag) {
if (_Py_GetConfig()->verbose) {
fprintf(stderr, "Python %s\n%s\n",
Py_GetVersion(), Py_GetCopyright());
}
Expand Down
2 changes: 1 addition & 1 deletion Tools/peg_generator/pegen/c_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "pegen.h"

#if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
# define D(x) if (Py_DebugFlag) x;
# define D(x) if (p->debug) { x; }
#else
# define D(x)
#endif
Expand Down