gh-81057: Move the Cached Parser Dummy Name to _PyRuntimeState (#100277)

This commit is contained in:
Eric Snow 2022-12-16 06:48:03 -07:00 committed by GitHub
parent 5ee7eb9deb
commit 0415cf895f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 25 deletions

View file

@ -9,6 +9,8 @@ extern "C" {
#endif
#include "pycore_ast.h" // struct _expr
#include "pycore_global_strings.h" // _Py_DECLARE_STR()
#include "pycore_pyarena.h" // PyArena
@ -22,9 +24,22 @@ struct _parser_runtime_state {
#else
int _not_used;
#endif
struct _expr dummy_name;
};
_Py_DECLARE_STR(empty, "")
#define _parser_runtime_state_INIT \
{ \
.dummy_name = { \
.kind = Name_kind, \
.v.Name.id = &_Py_STR(empty), \
.v.Name.ctx = Load, \
.lineno = 1, \
.col_offset = 0, \
.end_lineno = 1, \
.end_col_offset = 0, \
}, \
}
extern struct _mod* _PyParser_ASTFromString(
const char *str,