Skip to content

Commit 40c1272

Browse files
committed
py/compile: When compiling super(), handle closed-over self variable.
The self variable may be closed-over in the function, and in that case the call to super() should load the contents of the closure cell using LOAD_DEREF (before this patch it would just load the cell directly).
1 parent a0973b0 commit 40c1272

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

py/compile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,9 +2190,10 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
21902190
compile_load_id(comp, MP_QSTR___class__);
21912191
// look for first argument to function (assumes it's "self")
21922192
for (int i = 0; i < comp->scope_cur->id_info_len; i++) {
2193-
if (comp->scope_cur->id_info[i].flags & ID_FLAG_IS_PARAM) {
2193+
id_info_t *id = &comp->scope_cur->id_info[i];
2194+
if (id->flags & ID_FLAG_IS_PARAM) {
21942195
// first argument found; load it and call super
2195-
EMIT_LOAD_FAST(MP_QSTR_, comp->scope_cur->id_info[i].local_num);
2196+
compile_load_id(comp, id->qst);
21962197
EMIT_ARG(call_function, 2, 0, 0);
21972198
return;
21982199
}

0 commit comments

Comments
 (0)