mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +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
7 changed files with 14 additions and 4 deletions
2
Parser/parser.c
generated
2
Parser/parser.c
generated
|
@ -2,7 +2,7 @@
|
||||||
#include "pegen.h"
|
#include "pegen.h"
|
||||||
|
|
||||||
#if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
|
#if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
|
||||||
# define D(x) if (Py_DebugFlag) x;
|
# define D(x) if (p->debug) { x; }
|
||||||
#else
|
#else
|
||||||
# define D(x)
|
# define D(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -774,6 +774,9 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags,
|
||||||
p->known_err_token = NULL;
|
p->known_err_token = NULL;
|
||||||
p->level = 0;
|
p->level = 0;
|
||||||
p->call_invalid_rules = 0;
|
p->call_invalid_rules = 0;
|
||||||
|
#ifdef Py_DEBUG
|
||||||
|
p->debug = _Py_GetConfig()->parser_debug;
|
||||||
|
#endif
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ typedef struct {
|
||||||
Token *known_err_token;
|
Token *known_err_token;
|
||||||
int level;
|
int level;
|
||||||
int call_invalid_rules;
|
int call_invalid_rules;
|
||||||
|
int debug;
|
||||||
} Parser;
|
} Parser;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -88,6 +88,9 @@ tok_new(void)
|
||||||
tok->async_def_nl = 0;
|
tok->async_def_nl = 0;
|
||||||
tok->interactive_underflow = IUNDERFLOW_NORMAL;
|
tok->interactive_underflow = IUNDERFLOW_NORMAL;
|
||||||
tok->str = NULL;
|
tok->str = NULL;
|
||||||
|
#ifdef Py_DEBUG
|
||||||
|
tok->debug = _Py_GetConfig()->parser_debug;
|
||||||
|
#endif
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,7 +1024,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
rc = tok_underflow_file(tok);
|
rc = tok_underflow_file(tok);
|
||||||
}
|
}
|
||||||
#if defined(Py_DEBUG)
|
#if defined(Py_DEBUG)
|
||||||
if (Py_DebugFlag) {
|
if (tok->debug) {
|
||||||
fprintf(stderr, "line[%d] = ", tok->lineno);
|
fprintf(stderr, "line[%d] = ", tok->lineno);
|
||||||
print_escape(stderr, tok->cur, tok->inp - tok->cur);
|
print_escape(stderr, tok->cur, tok->inp - tok->cur);
|
||||||
fprintf(stderr, " tok->done = %d\n", tok->done);
|
fprintf(stderr, " tok->done = %d\n", tok->done);
|
||||||
|
|
|
@ -84,6 +84,9 @@ struct tok_state {
|
||||||
NEWLINE token after it. */
|
NEWLINE token after it. */
|
||||||
/* How to proceed when asked for a new token in interactive mode */
|
/* How to proceed when asked for a new token in interactive mode */
|
||||||
enum interactive_underflow_t interactive_underflow;
|
enum interactive_underflow_t interactive_underflow;
|
||||||
|
#ifdef Py_DEBUG
|
||||||
|
int debug;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct tok_state *_PyTokenizer_FromString(const char *, int);
|
extern struct tok_state *_PyTokenizer_FromString(const char *, int);
|
||||||
|
|
|
@ -53,7 +53,7 @@ Py_FrozenMain(int argc, char **argv)
|
||||||
PyWinFreeze_ExeInit();
|
PyWinFreeze_ExeInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Py_VerboseFlag) {
|
if (_Py_GetConfig()->verbose) {
|
||||||
fprintf(stderr, "Python %s\n%s\n",
|
fprintf(stderr, "Python %s\n%s\n",
|
||||||
Py_GetVersion(), Py_GetCopyright());
|
Py_GetVersion(), Py_GetCopyright());
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ EXTENSION_PREFIX = """\
|
||||||
#include "pegen.h"
|
#include "pegen.h"
|
||||||
|
|
||||||
#if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
|
#if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
|
||||||
# define D(x) if (Py_DebugFlag) x;
|
# define D(x) if (p->debug) { x; }
|
||||||
#else
|
#else
|
||||||
# define D(x)
|
# define D(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue