Permalink
Browse files

prevent tp_new() optimisation from breaking external types with known…

… typeobj
  • Loading branch information...
scoder committed Mar 29, 2013
1 parent dd29ccb commit 3257193a7865c1f45ac2479954be5569f0b8337e
Showing with 4 additions and 2 deletions.
  1. +3 −1 Cython/Compiler/Optimize.py
  2. +1 −1 tests/run/tp_new_cimport.srctree
@@ -2189,7 +2189,9 @@ def _handle_any_slot__new__(self, node, function, args,
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:
@@ -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 ########

0 comments on commit 3257193

Please sign in to comment.