diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2022-12-16 13:48:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-16 13:48:03 (GMT) |
commit | 0415cf895f96ae3f896f1f25f0c030a820845e13 (patch) | |
tree | 6f3a5c8d1bc2707a9f74574c3d7be947e593fa26 /Parser/action_helpers.c | |
parent | 5ee7eb9debb12914f36c5ccee92460a681516fd6 (diff) | |
download | cpython-0415cf895f96ae3f896f1f25f0c030a820845e13.zip cpython-0415cf895f96ae3f896f1f25f0c030a820845e13.tar.gz cpython-0415cf895f96ae3f896f1f25f0c030a820845e13.tar.bz2 |
gh-81057: Move the Cached Parser Dummy Name to _PyRuntimeState (#100277)
Diffstat (limited to 'Parser/action_helpers.c')
-rw-r--r-- | Parser/action_helpers.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c index f12dad0..4639096 100644 --- a/Parser/action_helpers.c +++ b/Parser/action_helpers.c @@ -2,30 +2,12 @@ #include "pegen.h" #include "string_parser.h" - -static PyObject * -_create_dummy_identifier(Parser *p) -{ - return _PyPegen_new_identifier(p, ""); -} +#include "pycore_runtime.h" // _PyRuntime void * _PyPegen_dummy_name(Parser *p, ...) { - // XXX This leaks memory from the initial arena. - // Use a statically allocated variable instead of a pointer? - static void *cache = NULL; - - if (cache != NULL) { - return cache; - } - - PyObject *id = _create_dummy_identifier(p); - if (!id) { - return NULL; - } - cache = _PyAST_Name(id, Load, 1, 0, 1, 0, p->arena); - return cache; + return &_PyRuntime.parser.dummy_name; } /* Creates a single-element asdl_seq* that contains a */ |