From 48a3ef68627b77b7f9e451aea0696fdf215b1cd3 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 7 Mar 2013 22:40:32 +0100 Subject: [PATCH] use direct call to tp_new() slot function in closure creation --- Cython/Compiler/Nodes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index b6b6bff..9ccba1e 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1634,10 +1634,14 @@ class FuncDefNode(StatNode, BlockNode): self.getbuffer_init(code) # ----- Create closure scope object if self.needs_closure: - code.putln("%s = (%s)%s->tp_new(%s, %s, NULL);" % ( + tp_slot = TypeSlots.ConstructorSlot("tp_new", '__new__') + slot_func_cname = TypeSlots.get_slot_function(lenv.scope_class.type.scope, tp_slot) + if not slot_func_cname: + slot_func_cname = '%s->tp_new' % lenv.scope_class.type.typeptr_cname + code.putln("%s = (%s)%s(%s, %s, NULL);" % ( Naming.cur_scope_cname, lenv.scope_class.type.declaration_code(''), - lenv.scope_class.type.typeptr_cname, + slot_func_cname, lenv.scope_class.type.typeptr_cname, Naming.empty_tuple)) code.putln("if (unlikely(!%s)) {" % Naming.cur_scope_cname) -- 2.7.4