prevent generating empty code section during vtable setup
authorStefan Behnel <scoder@users.berlios.de>
Mon, 2 Mar 2009 14:18:02 +0000 (15:18 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 2 Mar 2009 14:18:02 +0000 (15:18 +0100)
Cython/Compiler/ModuleNode.py

index 9127535eacacf169704d4b71efb3c4610d03148c..02da52022e7e8e08d0cee4a750106f8aa83046ed 100644 (file)
@@ -1971,23 +1971,24 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
             c_method_entries = [
                 entry for entry in type.scope.cfunc_entries
                 if entry.func_cname ]
-            code.putln('#if PY_MAJOR_VERSION >= 3')
-            for meth_entry in c_method_entries:
-                cast = meth_entry.type.signature_cast_string()
-                code.putln(
-                    "%s.%s = %s%s;" % (
-                        type.vtable_cname,
-                        meth_entry.cname,
-                        cast,
-                        meth_entry.func_cname))
-            code.putln('#else')
-            for meth_entry in c_method_entries:
-                code.putln(
-                    "*(void(**)(void))&%s.%s = (void(*)(void))%s;" % (
-                        type.vtable_cname,
-                        meth_entry.cname,
-                        meth_entry.func_cname))
-            code.putln('#endif')
+            if c_method_entries:
+                code.putln('#if PY_MAJOR_VERSION >= 3')
+                for meth_entry in c_method_entries:
+                    cast = meth_entry.type.signature_cast_string()
+                    code.putln(
+                        "%s.%s = %s%s;" % (
+                            type.vtable_cname,
+                            meth_entry.cname,
+                            cast,
+                            meth_entry.func_cname))
+                code.putln('#else')
+                for meth_entry in c_method_entries:
+                    code.putln(
+                        "*(void(**)(void))&%s.%s = (void(*)(void))%s;" % (
+                            type.vtable_cname,
+                            meth_entry.cname,
+                            meth_entry.func_cname))
+                code.putln('#endif')
     
     def generate_typeptr_assignment_code(self, entry, code):
         # Generate code to initialise the typeptr of an extension