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:
Victor Stinner 2022-05-24 22:35:08 +02:00 committed by GitHub
parent d2ef66a10b
commit 5115a16831
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 4 deletions

2
Parser/parser.c generated
View file

@ -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

View file

@ -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;
}

View file

@ -78,6 +78,7 @@ typedef struct {
Token *known_err_token;
int level;
int call_invalid_rules;
int debug;
} Parser;
typedef struct {

View file

@ -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);

View file

@ -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);

View file

@ -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());
}

View file

@ -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