summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2024-08-27 15:57:31 (GMT)
committerGitHub <noreply@github.com>2024-08-27 15:57:31 (GMT)
commitd24d1c986d2c55933f89c6b73b2e618448115f54 (patch)
tree6535372239a53a0fcf7aaf5432ddc01f037b2869 /Python
parent08c0166ce4cd5b54ec3cd57cd48b57b9bc2e8d3c (diff)
downloadcpython-d24d1c986d2c55933f89c6b73b2e618448115f54.zip
cpython-d24d1c986d2c55933f89c6b73b2e618448115f54.tar.gz
cpython-d24d1c986d2c55933f89c6b73b2e618448115f54.tar.bz2
gh-121404: split compiler_nameop into a codegen part and a compiler part (#123398)
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c190
1 files changed, 101 insertions, 89 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 3e762aa..3464723 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -107,6 +107,7 @@ static int compiler_optimization_level(struct compiler *c);
static int compiler_is_interactive(struct compiler *c);
static int compiler_is_nested_scope(struct compiler *c);
static int compiler_scope_type(struct compiler *c);
+static int compiler_is_in_inlined_comp(struct compiler *c);
static PyObject *compiler_qualname(struct compiler *c);
#define LOCATION(LNO, END_LNO, COL, END_COL) \
@@ -311,7 +312,7 @@ typedef struct {
static void compiler_free(struct compiler *);
static int compiler_error(struct compiler *, location loc, const char *, ...);
static int compiler_warn(struct compiler *, location loc, const char *, ...);
-static int compiler_nameop(struct compiler *, location, identifier, expr_context_ty);
+static int codegen_nameop(struct compiler *, location, identifier, expr_context_ty);
static PyCodeObject *compiler_mod(struct compiler *, mod_ty);
static int codegen_visit_stmt(struct compiler *, stmt_ty);
@@ -1419,8 +1420,8 @@ codegen_unwind_fblock(struct compiler *c, location *ploc,
ADDOP(c, *ploc, POP_EXCEPT);
if (info->fb_datum) {
ADDOP_LOAD_CONST(c, *ploc, Py_None);
- RETURN_IF_ERROR(compiler_nameop(c, *ploc, info->fb_datum, Store));
- RETURN_IF_ERROR(compiler_nameop(c, *ploc, info->fb_datum, Del));
+ RETURN_IF_ERROR(codegen_nameop(c, *ploc, info->fb_datum, Store));
+ RETURN_IF_ERROR(codegen_nameop(c, *ploc, info->fb_datum, Del));
}
return SUCCESS;
}
@@ -1553,12 +1554,8 @@ codegen_process_deferred_annotations(struct compiler *c, location loc)
}
Py_DECREF(deferred_anno);
- RETURN_IF_ERROR(
- codegen_leave_annotations_scope(c, loc, annotations_len)
- );
- RETURN_IF_ERROR(
- compiler_nameop(c, loc, &_Py_ID(__annotate__), Store)
- );
+ RETURN_IF_ERROR(codegen_leave_annotations_scope(c, loc, annotations_len));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, &_Py_ID(__annotate__), Store));
return SUCCESS;
}
@@ -1594,7 +1591,7 @@ codegen_body(struct compiler *c, location loc, asdl_stmt_seq *stmts)
location loc = LOC(st->v.Expr.value);
ADDOP_LOAD_CONST(c, loc, cleandoc);
Py_DECREF(cleandoc);
- RETURN_IF_ERROR(compiler_nameop(c, NO_LOCATION, &_Py_ID(__doc__), Store));
+ RETURN_IF_ERROR(codegen_nameop(c, NO_LOCATION, &_Py_ID(__doc__), Store));
}
}
}
@@ -2109,7 +2106,7 @@ codegen_type_params(struct compiler *c, asdl_type_param_seq *type_params)
typeparam->v.TypeVar.name);
}
ADDOP_I(c, loc, COPY, 1);
- RETURN_IF_ERROR(compiler_nameop(c, loc, typeparam->v.TypeVar.name, Store));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, typeparam->v.TypeVar.name, Store));
break;
case TypeVarTuple_kind:
ADDOP_LOAD_CONST(c, loc, typeparam->v.TypeVarTuple.name);
@@ -2128,7 +2125,7 @@ codegen_type_params(struct compiler *c, asdl_type_param_seq *type_params)
typeparam->v.TypeVarTuple.name);
}
ADDOP_I(c, loc, COPY, 1);
- RETURN_IF_ERROR(compiler_nameop(c, loc, typeparam->v.TypeVarTuple.name, Store));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, typeparam->v.TypeVarTuple.name, Store));
break;
case ParamSpec_kind:
ADDOP_LOAD_CONST(c, loc, typeparam->v.ParamSpec.name);
@@ -2147,7 +2144,7 @@ codegen_type_params(struct compiler *c, asdl_type_param_seq *type_params)
typeparam->v.ParamSpec.name);
}
ADDOP_I(c, loc, COPY, 1);
- RETURN_IF_ERROR(compiler_nameop(c, loc, typeparam->v.ParamSpec.name, Store));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, typeparam->v.ParamSpec.name, Store));
break;
}
}
@@ -2356,15 +2353,15 @@ codegen_function(struct compiler *c, stmt_ty s, int is_async)
}
RETURN_IF_ERROR(codegen_apply_decorators(c, decos));
- return compiler_nameop(c, loc, name, Store);
+ return codegen_nameop(c, loc, name, Store);
}
static int
codegen_set_type_params_in_class(struct compiler *c, location loc)
{
_Py_DECLARE_STR(type_params, ".type_params");
- RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load));
- RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_ID(__type_params__), Store));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, &_Py_STR(type_params), Load));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, &_Py_ID(__type_params__), Store));
return SUCCESS;
}
@@ -2396,13 +2393,13 @@ codegen_class_body(struct compiler *c, stmt_ty s, int firstlineno)
location loc = LOCATION(firstlineno, firstlineno, 0, 0);
/* load (global) __name__ ... */
- RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_ID(__name__), Load));
+ RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_ID(__name__), Load));
/* ... and store it as __module__ */
- RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_ID(__module__), Store));
+ RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_ID(__module__), Store));
ADDOP_LOAD_CONST(c, loc, QUALNAME(c));
- RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_ID(__qualname__), Store));
+ RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_ID(__qualname__), Store));
ADDOP_LOAD_CONST_NEW(c, loc, PyLong_FromLong(c->u->u_metadata.u_firstlineno));
- RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_ID(__firstlineno__), Store));
+ RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_ID(__firstlineno__), Store));
asdl_type_param_seq *type_params = s->v.ClassDef.type_params;
if (asdl_seq_LEN(type_params) > 0) {
RETURN_IF_ERROR_IN_SCOPE(c, codegen_set_type_params_in_class(c, loc));
@@ -2410,8 +2407,8 @@ codegen_class_body(struct compiler *c, stmt_ty s, int firstlineno)
if (SYMTABLE_ENTRY(c)->ste_needs_classdict) {
ADDOP(c, loc, LOAD_LOCALS);
- // We can't use compiler_nameop here because we need to generate a
- // STORE_DEREF in a class namespace, and compiler_nameop() won't do
+ // We can't use codegen_nameop here because we need to generate a
+ // STORE_DEREF in a class namespace, and codegen_nameop() won't do
// that by default.
ADDOP_N_IN_SCOPE(c, loc, STORE_DEREF, &_Py_ID(__classdict__), cellvars);
}
@@ -2425,7 +2422,7 @@ codegen_class_body(struct compiler *c, stmt_ty s, int firstlineno)
ADDOP_LOAD_CONST(c, NO_LOCATION, static_attributes);
Py_CLEAR(static_attributes);
RETURN_IF_ERROR_IN_SCOPE(
- c, compiler_nameop(c, NO_LOCATION, &_Py_ID(__static_attributes__), Store));
+ c, codegen_nameop(c, NO_LOCATION, &_Py_ID(__static_attributes__), Store));
/* The following code is artificial */
/* Set __classdictcell__ if necessary */
if (SYMTABLE_ENTRY(c)->ste_needs_classdict) {
@@ -2434,7 +2431,7 @@ codegen_class_body(struct compiler *c, stmt_ty s, int firstlineno)
RETURN_IF_ERROR_IN_SCOPE(c, i);
ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i);
RETURN_IF_ERROR_IN_SCOPE(
- c, compiler_nameop(c, NO_LOCATION, &_Py_ID(__classdictcell__), Store));
+ c, codegen_nameop(c, NO_LOCATION, &_Py_ID(__classdictcell__), Store));
}
/* Return __classcell__ if it is referenced, otherwise return None */
if (SYMTABLE_ENTRY(c)->ste_needs_class_closure) {
@@ -2444,7 +2441,7 @@ codegen_class_body(struct compiler *c, stmt_ty s, int firstlineno)
ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i);
ADDOP_I(c, NO_LOCATION, COPY, 1);
RETURN_IF_ERROR_IN_SCOPE(
- c, compiler_nameop(c, NO_LOCATION, &_Py_ID(__classcell__), Store));
+ c, codegen_nameop(c, NO_LOCATION, &_Py_ID(__classcell__), Store));
}
else {
/* No methods referenced __class__, so just return None */
@@ -2506,7 +2503,7 @@ codegen_class(struct compiler *c, stmt_ty s)
RETURN_IF_ERROR(ret);
RETURN_IF_ERROR_IN_SCOPE(c, codegen_type_params(c, type_params));
_Py_DECLARE_STR(type_params, ".type_params");
- RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Store));
+ RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_STR(type_params), Store));
}
int ret = codegen_class_body(c, s, firstlineno);
@@ -2522,9 +2519,9 @@ codegen_class(struct compiler *c, stmt_ty s)
if (is_generic) {
_Py_DECLARE_STR(type_params, ".type_params");
_Py_DECLARE_STR(generic_base, ".generic_base");
- RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Load));
+ RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_STR(type_params), Load));
ADDOP_I_IN_SCOPE(c, loc, CALL_INTRINSIC_1, INTRINSIC_SUBSCRIPT_GENERIC);
- RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(generic_base), Store));
+ RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_STR(generic_base), Store));
Py_ssize_t original_len = asdl_seq_LEN(s->v.ClassDef.bases);
asdl_expr_seq *bases = _Py_asdl_expr_seq_new(
@@ -2570,7 +2567,7 @@ codegen_class(struct compiler *c, stmt_ty s)
RETURN_IF_ERROR(codegen_apply_decorators(c, decos));
/* 7. store into <name> */
- RETURN_IF_ERROR(compiler_nameop(c, loc, s->v.ClassDef.name, Store));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, s->v.ClassDef.name, Store));
return SUCCESS;
}
@@ -2647,7 +2644,7 @@ codegen_typealias(struct compiler *c, stmt_ty s)
ADDOP(c, loc, PUSH_NULL);
ADDOP_I(c, loc, CALL, 0);
}
- RETURN_IF_ERROR(compiler_nameop(c, loc, name, Store));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, name, Store));
return SUCCESS;
}
@@ -3340,7 +3337,7 @@ codegen_try_except(struct compiler *c, stmt_ty s)
NEW_JUMP_TARGET_LABEL(c, cleanup_body);
RETURN_IF_ERROR(
- compiler_nameop(c, loc, handler->v.ExceptHandler.name, Store));
+ codegen_nameop(c, loc, handler->v.ExceptHandler.name, Store));
/*
try:
@@ -3370,9 +3367,9 @@ codegen_try_except(struct compiler *c, stmt_ty s)
ADDOP(c, NO_LOCATION, POP_EXCEPT);
ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None);
RETURN_IF_ERROR(
- compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store));
+ codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store));
RETURN_IF_ERROR(
- compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del));
+ codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del));
ADDOP_JUMP(c, NO_LOCATION, JUMP_NO_INTERRUPT, end);
/* except: */
@@ -3381,9 +3378,9 @@ codegen_try_except(struct compiler *c, stmt_ty s)
/* name = None; del name; # artificial */
ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None);
RETURN_IF_ERROR(
- compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store));
+ codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store));
RETURN_IF_ERROR(
- compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del));
+ codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del));
ADDOP_I(c, NO_LOCATION, RERAISE, 1);
}
@@ -3535,7 +3532,7 @@ codegen_try_star_except(struct compiler *c, stmt_ty s)
if (handler->v.ExceptHandler.name) {
RETURN_IF_ERROR(
- compiler_nameop(c, loc, handler->v.ExceptHandler.name, Store));
+ codegen_nameop(c, loc, handler->v.ExceptHandler.name, Store));
}
else {
ADDOP(c, loc, POP_TOP); // match
@@ -3567,9 +3564,9 @@ codegen_try_star_except(struct compiler *c, stmt_ty s)
if (handler->v.ExceptHandler.name) {
ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None);
RETURN_IF_ERROR(
- compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store));
+ codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store));
RETURN_IF_ERROR(
- compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del));
+ codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del));
}
ADDOP_JUMP(c, NO_LOCATION, JUMP_NO_INTERRUPT, except);
@@ -3580,9 +3577,9 @@ codegen_try_star_except(struct compiler *c, stmt_ty s)
if (handler->v.ExceptHandler.name) {
ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None);
RETURN_IF_ERROR(
- compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store));
+ codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store));
RETURN_IF_ERROR(
- compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del));
+ codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del));
}
/* add exception raised to the res list */
@@ -3690,11 +3687,11 @@ codegen_import_as(struct compiler *c, location loc,
ADDOP_I(c, loc, SWAP, 2);
ADDOP(c, loc, POP_TOP);
}
- RETURN_IF_ERROR(compiler_nameop(c, loc, asname, Store));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, asname, Store));
ADDOP(c, loc, POP_TOP);
return SUCCESS;
}
- return compiler_nameop(c, loc, asname, Store);
+ return codegen_nameop(c, loc, asname, Store);
}
static int
@@ -3733,7 +3730,7 @@ codegen_import(struct compiler *c, stmt_ty s)
return ERROR;
}
}
- r = compiler_nameop(c, loc, tmp, Store);
+ r = codegen_nameop(c, loc, tmp, Store);
if (dot != -1) {
Py_DECREF(tmp);
}
@@ -3787,7 +3784,7 @@ codegen_from_import(struct compiler *c, stmt_ty s)
store_name = alias->asname;
}
- RETURN_IF_ERROR(compiler_nameop(c, LOC(s), store_name, Store));
+ RETURN_IF_ERROR(codegen_nameop(c, LOC(s), store_name, Store));
}
/* remove imported module */
ADDOP(c, LOC(s), POP_TOP);
@@ -4031,76 +4028,89 @@ codegen_load_classdict_freevar(struct compiler *c, location loc)
return SUCCESS;
}
+typedef enum { OP_FAST, OP_GLOBAL, OP_DEREF, OP_NAME } compiler_optype;
+
static int
-compiler_nameop(struct compiler *c, location loc,
- identifier name, expr_context_ty ctx)
+compiler_resolve_nameop(struct compiler *c, PyObject *mangled, int scope,
+ compiler_optype *optype, Py_ssize_t *arg)
{
- int op, scope;
- Py_ssize_t arg;
- enum { OP_FAST, OP_GLOBAL, OP_DEREF, OP_NAME } optype;
-
PyObject *dict = c->u->u_metadata.u_names;
- PyObject *mangled;
-
- assert(!_PyUnicode_EqualToASCIIString(name, "None") &&
- !_PyUnicode_EqualToASCIIString(name, "True") &&
- !_PyUnicode_EqualToASCIIString(name, "False"));
-
- mangled = compiler_maybe_mangle(c, name);
- if (!mangled) {
- return ERROR;
- }
+ *optype = OP_NAME;
- op = 0;
- optype = OP_NAME;
- scope = _PyST_GetScope(SYMTABLE_ENTRY(c), mangled);
+ assert(scope >= 0);
switch (scope) {
case FREE:
dict = c->u->u_metadata.u_freevars;
- optype = OP_DEREF;
+ *optype = OP_DEREF;
break;
case CELL:
dict = c->u->u_metadata.u_cellvars;
- optype = OP_DEREF;
+ *optype = OP_DEREF;
break;
case LOCAL:
if (_PyST_IsFunctionLike(SYMTABLE_ENTRY(c))) {
- optype = OP_FAST;
+ *optype = OP_FAST;
}
else {
PyObject *item;
- if (PyDict_GetItemRef(c->u->u_metadata.u_fasthidden, mangled,
- &item) < 0) {
- goto error;
- }
+ RETURN_IF_ERROR(PyDict_GetItemRef(c->u->u_metadata.u_fasthidden, mangled,
+ &item));
if (item == Py_True) {
- optype = OP_FAST;
+ *optype = OP_FAST;
}
Py_XDECREF(item);
}
break;
case GLOBAL_IMPLICIT:
- if (_PyST_IsFunctionLike(SYMTABLE_ENTRY(c)))
- optype = OP_GLOBAL;
+ if (_PyST_IsFunctionLike(SYMTABLE_ENTRY(c))) {
+ *optype = OP_GLOBAL;
+ }
break;
case GLOBAL_EXPLICIT:
- optype = OP_GLOBAL;
+ *optype = OP_GLOBAL;
break;
- case -1:
- goto error;
default:
/* scope can be 0 */
break;
}
+ if (*optype != OP_FAST) {
+ *arg = dict_add_o(dict, mangled);
+ RETURN_IF_ERROR(*arg);
+ }
+ return SUCCESS;
+}
+
+static int
+codegen_nameop(struct compiler *c, location loc,
+ identifier name, expr_context_ty ctx)
+{
+ assert(!_PyUnicode_EqualToASCIIString(name, "None") &&
+ !_PyUnicode_EqualToASCIIString(name, "True") &&
+ !_PyUnicode_EqualToASCIIString(name, "False"));
+
+ PyObject *mangled = compiler_maybe_mangle(c, name);
+ if (!mangled) {
+ return ERROR;
+ }
+
+ int scope = _PyST_GetScope(SYMTABLE_ENTRY(c), mangled);
+ RETURN_IF_ERROR(scope);
+ compiler_optype optype;
+ Py_ssize_t arg = 0;
+ if (compiler_resolve_nameop(c, mangled, scope, &optype, &arg) < 0) {
+ Py_DECREF(mangled);
+ return ERROR;
+ }
/* XXX Leave assert here, but handle __doc__ and the like better */
assert(scope || PyUnicode_READ_CHAR(name, 0) == '_');
+ int op = 0;
switch (optype) {
case OP_DEREF:
switch (ctx) {
case Load:
- if (SYMTABLE_ENTRY(c)->ste_type == ClassBlock && !c->u->u_in_inlined_comp) {
+ if (SYMTABLE_ENTRY(c)->ste_type == ClassBlock && !compiler_is_in_inlined_comp(c)) {
op = LOAD_FROM_DICT_OR_DEREF;
// First load the locals
if (codegen_addop_noarg(INSTR_SEQUENCE(c), LOAD_LOCALS, loc) < 0) {
@@ -4151,7 +4161,7 @@ compiler_nameop(struct compiler *c, location loc,
switch (ctx) {
case Load:
op = (SYMTABLE_ENTRY(c)->ste_type == ClassBlock
- && c->u->u_in_inlined_comp)
+ && compiler_is_in_inlined_comp(c))
? LOAD_GLOBAL
: LOAD_NAME;
break;
@@ -4162,11 +4172,7 @@ compiler_nameop(struct compiler *c, location loc,
}
assert(op);
- arg = dict_add_o(dict, mangled);
Py_DECREF(mangled);
- if (arg < 0) {
- return ERROR;
- }
if (op == LOAD_GLOBAL) {
arg <<= 1;
}
@@ -4705,7 +4711,7 @@ load_args_for_super(struct compiler *c, expr_ty e) {
// load super() global
PyObject *super_name = e->v.Call.func->v.Name.id;
- RETURN_IF_ERROR(compiler_nameop(c, LOC(e->v.Call.func), super_name, Load));
+ RETURN_IF_ERROR(codegen_nameop(c, LOC(e->v.Call.func), super_name, Load));
if (asdl_seq_LEN(e->v.Call.args) == 2) {
VISIT(c, expr, asdl_seq_GET(e->v.Call.args, 0));
@@ -4716,7 +4722,7 @@ load_args_for_super(struct compiler *c, expr_ty e) {
// load __class__ cell
PyObject *name = &_Py_ID(__class__);
assert(compiler_get_ref_type(c, name) == FREE);
- RETURN_IF_ERROR(compiler_nameop(c, loc, name, Load));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, name, Load));
// load self (first argument)
Py_ssize_t i = 0;
@@ -4724,7 +4730,7 @@ load_args_for_super(struct compiler *c, expr_ty e) {
if (!PyDict_Next(c->u->u_metadata.u_varnames, &i, &key, &value)) {
return ERROR;
}
- RETURN_IF_ERROR(compiler_nameop(c, loc, key, Load));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, key, Load));
return SUCCESS;
}
@@ -6171,7 +6177,7 @@ codegen_visit_expr(struct compiler *c, expr_ty e)
break;
}
case Name_kind:
- return compiler_nameop(c, loc, e->v.Name.id, e->v.Name.ctx);
+ return codegen_nameop(c, loc, e->v.Name.id, e->v.Name.ctx);
/* child nodes of List and Tuple will have expr_context set */
case List_kind:
return codegen_list(c, e);
@@ -6220,7 +6226,7 @@ codegen_augassign(struct compiler *c, stmt_ty s)
}
break;
case Name_kind:
- RETURN_IF_ERROR(compiler_nameop(c, loc, e->v.Name.id, Load));
+ RETURN_IF_ERROR(codegen_nameop(c, loc, e->v.Name.id, Load));
break;
default:
PyErr_Format(PyExc_SystemError,
@@ -6256,7 +6262,7 @@ codegen_augassign(struct compiler *c, stmt_ty s)
}
break;
case Name_kind:
- return compiler_nameop(c, loc, e->v.Name.id, Store);
+ return codegen_nameop(c, loc, e->v.Name.id, Store);
default:
Py_UNREACHABLE();
}
@@ -7297,7 +7303,7 @@ codegen_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc)
Py_ssize_t nstores = PyList_GET_SIZE(pc->stores);
for (Py_ssize_t n = 0; n < nstores; n++) {
PyObject *name = PyList_GET_ITEM(pc->stores, n);
- if (compiler_nameop(c, LOC(m->pattern), name, Store) < 0) {
+ if (codegen_nameop(c, LOC(m->pattern), name, Store) < 0) {
Py_DECREF(pc->stores);
return ERROR;
}
@@ -7440,6 +7446,12 @@ compiler_scope_type(struct compiler *c)
return c->u->u_scope_type;
}
+static int
+compiler_is_in_inlined_comp(struct compiler *c)
+{
+ return c->u->u_in_inlined_comp;
+}
+
static PyObject *
compiler_qualname(struct compiler *c)
{