Commit 3257193a authored by Stefan Behnel's avatar Stefan Behnel

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

parent dd29ccbe
......@@ -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:
......
......@@ -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 ########
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment