diff --git a/py/compile.c b/py/compile.c
index 0699692df4a7323daa9e55cdaca5141f4be2d660..9213fd22f5bbcc0d2d13b80ff9237f636e32bf72 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -1970,6 +1970,10 @@ STATIC void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) {
     comp->func_arg_is_super = MP_PARSE_NODE_IS_ID(pns->nodes[0]) && MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]) == MP_QSTR_super;
 
     compile_generic_all_nodes(comp, pns);
+
+    if (!MP_PARSE_NODE_IS_NULL(pns->nodes[2])) {
+        EMIT_ARG(binary_op, MP_BINARY_OP_POWER);
+    }
 }
 
 STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_arglist, bool is_method_call, int n_positional_extra) {
@@ -2087,11 +2091,6 @@ STATIC void compile_power_trailers(compiler_t *comp, mp_parse_node_struct_t *pns
     }
 }
 
-STATIC void compile_power_dbl_star(compiler_t *comp, mp_parse_node_struct_t *pns) {
-    compile_node(comp, pns->nodes[0]);
-    EMIT_ARG(binary_op, MP_BINARY_OP_POWER);
-}
-
 STATIC void compile_atom_string(compiler_t *comp, mp_parse_node_struct_t *pns) {
     // a list of strings
 
diff --git a/py/grammar.h b/py/grammar.h
index b7036c8ecde22e8fae9af1457f9a2a245bf1ba3b..a7d1b41e6cbffabfbd0dd6e5cad9b9822ad3607d 100644
--- a/py/grammar.h
+++ b/py/grammar.h
@@ -241,7 +241,7 @@ DEF_RULE(factor_2, c(factor_2), and(2), rule(factor_op), rule(factor))
 DEF_RULE(factor_op, nc, or(3), tok(OP_PLUS), tok(OP_MINUS), tok(OP_TILDE))
 DEF_RULE(power, c(power), and(3), rule(atom), opt_rule(power_trailers), opt_rule(power_dbl_star))
 DEF_RULE(power_trailers, c(power_trailers), one_or_more, rule(trailer))
-DEF_RULE(power_dbl_star, c(power_dbl_star), and(2), tok(OP_DBL_STAR), rule(factor))
+DEF_RULE(power_dbl_star, nc, ident | and(2), tok(OP_DBL_STAR), rule(factor))
 
 // atom: '(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictorsetmaker] '}' | NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False'
 // testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )