avoid generating empty PyMethodDef array for types (especially closures)
authorStefan Behnel <stefan_ml@behnel.de>
Sat, 10 Aug 2013 10:12:45 +0000 (12:12 +0200)
committerStefan Behnel <stefan_ml@behnel.de>
Sat, 10 Aug 2013 10:12:45 +0000 (12:12 +0200)
Cython/Compiler/ModuleNode.py
Cython/Compiler/TypeSlots.py

index a482042..db7266e 100644 (file)
@@ -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[] = {" %
index 118c704..089d039 100644 (file)
@@ -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):