From: Stefan Behnel Date: Fri, 11 Dec 2009 14:46:18 +0000 (+0100) Subject: fix crash when calling non-trivial type constructors X-Git-Tag: 0.12.1~42 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ff35cf52cc5404eb0023b4880e89f281a5e7d4c0;p=cython.git fix crash when calling non-trivial type constructors --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 57572fdb..d2789833 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -2471,7 +2471,9 @@ class SimpleCallNode(CallNode): self.arg_tuple = TupleNode(self.pos, args = self.args) self.arg_tuple.analyse_types(env) self.args = None - if func_type is Builtin.type_type and function.entry.is_builtin and \ + if func_type is Builtin.type_type and function.is_name and \ + function.entry and \ + function.entry.is_builtin and \ function.entry.name in Builtin.types_that_construct_their_instance: # calling a builtin type that returns a specific object type if function.entry.name == 'float': diff --git a/tests/run/clone_type.pyx b/tests/run/clone_type.pyx new file mode 100644 index 00000000..dd5cc7b8 --- /dev/null +++ b/tests/run/clone_type.pyx @@ -0,0 +1,14 @@ +cdef class MyType: + def dup(self): + """ + >>> x1 = MyType() + >>> isinstance(x1, MyType) + True + >>> x2 = x1.dup() + >>> isinstance(x2, MyType) + True + >>> x1 != x2 + True + """ + cdef MyType clone = type(self)() + return clone