From: Stefan Behnel Date: Fri, 29 Mar 2013 20:21:14 +0000 (+0100) Subject: prevent tp_new() optimisation from breaking external types with known typeobj X-Git-Tag: 0.19b1~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3257193a7865c1f45ac2479954be5569f0b8337e;p=platform%2Fupstream%2Fpython-cython.git prevent tp_new() optimisation from breaking external types with known typeobj --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index ea11aa3..5660c2f 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -2189,7 +2189,9 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform): if type_arg.type_entry: ext_type = type_arg.type_entry.type - if ext_type.is_extension_type and ext_type.typeobj_cname: + if (ext_type.is_extension_type and ext_type.typeobj_cname and + ext_type.scope.global_scope() == self.current_env().global_scope()): + # known type in current module tp_slot = TypeSlots.ConstructorSlot("tp_new", '__new__') slot_func_cname = TypeSlots.get_slot_function(ext_type.scope, tp_slot) if slot_func_cname: diff --git a/tests/run/tp_new_cimport.srctree b/tests/run/tp_new_cimport.srctree index d60d712..632172c 100644 --- a/tests/run/tp_new_cimport.srctree +++ b/tests/run/tp_new_cimport.srctree @@ -42,7 +42,7 @@ def test_sub(): ######## a.pxd ######## -cdef class ExtTypeA: +cdef api class ExtTypeA[type ExtTypeA_Type, object ExtTypeAObject]: cdef readonly attrA ######## a.pyx ########