mirror of
https://github.com/python/cpython
synced 2024-10-02 23:59:15 +00:00
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.
This commit is contained in:
parent
d2ef66a10b
commit
5115a16831
2
Parser/parser.c
generated
2
Parser/parser.c
generated
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@ typedef struct {
|
|||
Token *known_err_token;
|
||||
int level;
|
||||
int call_invalid_rules;
|
||||
int debug;
|
||||
} Parser;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue