From 804760bfca9bb8d49fe57e107375336eac9d3f79 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 30 Mar 2014 23:06:37 +0100 Subject: [PATCH] py: Fix bug in compiler for empty class bases. Eg class A(): pass would fail an assertion. --- py/compile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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;