summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-24 20:35:08 (GMT)
committerGitHub <noreply@github.com>2022-05-24 20:35:08 (GMT)
commit5115a1683154a1f2093aa7f2c6834e47d326cb7d (patch)
tree21d7aabb9346aaa6285ce1598225fdd6da350149 /Parser
parentd2ef66a10be1250b13c32fbf3c0f9a9d2d98b124 (diff)
downloadcpython-5115a1683154a1f2093aa7f2c6834e47d326cb7d.zip
cpython-5115a1683154a1f2093aa7f2c6834e47d326cb7d.tar.gz
cpython-5115a1683154a1f2093aa7f2c6834e47d326cb7d.tar.bz2
gh-93103: Parser uses PyConfig.parser_debug instead of Py_DebugFlag (#93106)
* Replace deprecated Py_DebugFlag with PyConfig.parser_debug in the parser. * Add Parser.debug member. * Add tok_state.debug member. * Py_FrozenMain(): Replace Py_VerboseFlag with PyConfig.verbose.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/parser.c2
-rw-r--r--Parser/pegen.c3
-rw-r--r--Parser/pegen.h1
-rw-r--r--Parser/tokenizer.c5
-rw-r--r--Parser/tokenizer.h3
5 files changed, 12 insertions, 2 deletions
diff --git a/Parser/parser.c b/Parser/parser.c
index 08bf6d2..31ad9a0 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -2,7 +2,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
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 143461d..ec4fee3 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -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;
}
diff --git a/Parser/pegen.h b/Parser/pegen.h
index d6a6e4e..d8ac7e8 100644
--- a/Parser/pegen.h
+++ b/Parser/pegen.h
@@ -78,6 +78,7 @@ typedef struct {
Token *known_err_token;
int level;
int call_invalid_rules;
+ int debug;
} Parser;
typedef struct {
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 7c79718..b34dade 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -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;
}
@@ -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);
diff --git a/Parser/tokenizer.h b/Parser/tokenizer.h
index dba71bd..5ac64a9 100644
--- a/Parser/tokenizer.h
+++ b/Parser/tokenizer.h
@@ -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);