From a30385807d0b51bfa91efbaa493f1a138d6f98dc Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Mon, 2 Mar 2009 15:18:02 +0100 Subject: [PATCH] prevent generating empty code section during vtable setup --- Cython/Compiler/ModuleNode.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 9127535e..02da5202 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -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 -- 2.26.2