diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2022-02-15 00:36:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-15 00:36:51 (GMT) |
commit | 12360aa159c42c7798fd14225d271e6fd84db7eb (patch) | |
tree | ad2b4f0d67c90a5a0be4ff532082fc3468d6d65b /Python/compile.c | |
parent | 278fdd3e3a2492665b2c2888fd2f428f7f59a3f5 (diff) | |
download | cpython-12360aa159c42c7798fd14225d271e6fd84db7eb.zip cpython-12360aa159c42c7798fd14225d271e6fd84db7eb.tar.gz cpython-12360aa159c42c7798fd14225d271e6fd84db7eb.tar.bz2 |
bpo-46541: Discover the global strings. (gh-31346)
Instead of manually enumerating the global strings in generate_global_objects.py, we extrapolate the list from usage of _Py_ID() and _Py_STR() in the source files.
This is partly inspired by gh-31261.
https://bugs.python.org/issue46541
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c index ac4960b..1cf20d3 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -667,6 +667,7 @@ compiler_set_qualname(struct compiler *c) || parent->u_scope_type == COMPILER_SCOPE_ASYNC_FUNCTION || parent->u_scope_type == COMPILER_SCOPE_LAMBDA) { + _Py_DECLARE_STR(dot_locals, ".<locals>"); base = PyUnicode_Concat(parent->u_qualname, &_Py_STR(dot_locals)); if (base == NULL) @@ -2022,6 +2023,7 @@ compiler_mod(struct compiler *c, mod_ty mod) { PyCodeObject *co; int addNone = 1; + _Py_DECLARE_STR(anon_module, "<module>"); if (!compiler_enter_scope(c, &_Py_STR(anon_module), COMPILER_SCOPE_MODULE, mod, 1)) { return NULL; @@ -2876,6 +2878,7 @@ compiler_lambda(struct compiler *c, expr_ty e) return 0; } + _Py_DECLARE_STR(anon_lambda, "<lambda>"); if (!compiler_enter_scope(c, &_Py_STR(anon_lambda), COMPILER_SCOPE_LAMBDA, (void *)e, e->lineno)) { return 0; @@ -5347,6 +5350,7 @@ static int compiler_genexp(struct compiler *c, expr_ty e) { assert(e->kind == GeneratorExp_kind); + _Py_DECLARE_STR(anon_genexpr, "<genexpr>"); return compiler_comprehension(c, e, COMP_GENEXP, &_Py_STR(anon_genexpr), e->v.GeneratorExp.generators, e->v.GeneratorExp.elt, NULL); @@ -5356,6 +5360,7 @@ static int compiler_listcomp(struct compiler *c, expr_ty e) { assert(e->kind == ListComp_kind); + _Py_DECLARE_STR(anon_listcomp, "<listcomp>"); return compiler_comprehension(c, e, COMP_LISTCOMP, &_Py_STR(anon_listcomp), e->v.ListComp.generators, e->v.ListComp.elt, NULL); @@ -5365,6 +5370,7 @@ static int compiler_setcomp(struct compiler *c, expr_ty e) { assert(e->kind == SetComp_kind); + _Py_DECLARE_STR(anon_setcomp, "<setcomp>"); return compiler_comprehension(c, e, COMP_SETCOMP, &_Py_STR(anon_setcomp), e->v.SetComp.generators, e->v.SetComp.elt, NULL); @@ -5375,6 +5381,7 @@ static int compiler_dictcomp(struct compiler *c, expr_ty e) { assert(e->kind == DictComp_kind); + _Py_DECLARE_STR(anon_dictcomp, "<dictcomp>"); return compiler_comprehension(c, e, COMP_DICTCOMP, &_Py_STR(anon_dictcomp), e->v.DictComp.generators, e->v.DictComp.key, e->v.DictComp.value); |