From 23ef44c7b26041b32d7274fb485f84a03df654ce Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 10 Aug 2013 12:12:45 +0200 Subject: [PATCH] avoid generating empty PyMethodDef array for types (especially closures) --- Cython/Compiler/ModuleNode.py | 2 ++ Cython/Compiler/TypeSlots.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index a482042..db7266e 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1820,6 +1820,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): "};") def generate_method_table(self, env, code): + if env.is_c_class_scope and not env.pyfunc_entries: + return code.putln("") code.putln( "static PyMethodDef %s[] = {" % diff --git a/Cython/Compiler/TypeSlots.py b/Cython/Compiler/TypeSlots.py index 118c704..089d039 100644 --- a/Cython/Compiler/TypeSlots.py +++ b/Cython/Compiler/TypeSlots.py @@ -460,7 +460,10 @@ class MethodTableSlot(SlotDescriptor): # Slot descriptor for the method table. def slot_code(self, scope): - return scope.method_table_cname + if scope.pyfunc_entries: + return scope.method_table_cname + else: + return "0" class MemberTableSlot(SlotDescriptor): -- 2.7.4