summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--Python/frozenmain.c2
-rw-r--r--Tools/peg_generator/pegen/c_generator.py2
7 files changed, 14 insertions, 4 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);
diff --git a/Python/frozenmain.c b/Python/frozenmain.c
index 8743e08..f8be165 100644
--- a/Python/frozenmain.c
+++ b/Python/frozenmain.c
@@ -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());
}
diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py
index 65bfd59..31bb505 100644
--- a/Tools/peg_generator/pegen/c_generator.py
+++ b/Tools/peg_generator/pegen/c_generator.py
@@ -32,7 +32,7 @@ EXTENSION_PREFIX = """\
#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