summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-03-30 23:06:37 +0100
committerDamien George <damien.p.george@gmail.com>2014-03-30 23:06:37 +0100
commit804760bfca9bb8d49fe57e107375336eac9d3f79 (patch)
treeb722e5e41011454f65485e8cdeba9248311b04d3
parent0997af932fa1c013de82922cea8dfca6399b51a3 (diff)
downloadmicropython-804760bfca9bb8d49fe57e107375336eac9d3f79.tar.gz
micropython-804760bfca9bb8d49fe57e107375336eac9d3f79.zip
py: Fix bug in compiler for empty class bases.
Eg class A(): pass would fail an assertion.
-rw-r--r--py/compile.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/py/compile.c b/py/compile.c
index b32bc7e69c..c6c6752d16 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -955,8 +955,13 @@ qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint
EMIT_ARG(load_const_id, cscope->simple_name);
// nodes[1] has parent classes, if any
+ // empty parenthesis (eg class C():) gets here as an empty PN_classdef_2 and needs special handling
+ mp_parse_node_t parents = pns->nodes[1];
+ if (MP_PARSE_NODE_IS_STRUCT_KIND(parents, PN_classdef_2)) {
+ parents = MP_PARSE_NODE_NULL;
+ }
comp->func_arg_is_super = false;
- compile_trailer_paren_helper(comp, pns->nodes[1], false, 2);
+ compile_trailer_paren_helper(comp, parents, false, 2);
// return its name (the 'C' in class C(...):")
return cscope->simple_name;