From: Stefan Behnel Date: Sat, 31 Oct 2009 14:35:48 +0000 (+0100) Subject: fix C assignment issue for the typed target case X-Git-Tag: 0.12.alpha0~8^2~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=da1acf30545d72207759ac3ecb79fe0aa0201961;p=cython.git fix C assignment issue for the typed target case --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 44a9cda0..c8258ef4 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -756,7 +756,9 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): ### cleanup to avoid redundant coercions to/from Python types - def visit_PyTypeTestNode(self, node): + def _visit_PyTypeTestNode(self, node): + # disabled - appears to break assignments in some cases, and + # also drops a None check, which might still be required """Flatten redundant type checks after tree changes. """ old_arg = node.arg @@ -1073,7 +1075,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): # of the extension type and call that instead of the generic slot func_type = PyrexTypes.CFuncType( return_type, [ - PyrexTypes.CFuncTypeArg("type", PyrexTypes.py_object_type, None) + PyrexTypes.CFuncTypeArg("type", Builtin.type_type, None) ]) if not type_arg.type_entry: diff --git a/tests/run/tp_new.pyx b/tests/run/tp_new.pyx index d176fc3b..01f06827 100644 --- a/tests/run/tp_new.pyx +++ b/tests/run/tp_new.pyx @@ -29,6 +29,17 @@ def make_new(): m = MyType.__new__(MyType) return m +@cython.test_assert_path_exists('//PythonCapiCallNode') +@cython.test_fail_if_path_exists('//SimpleCallNode/AttributeNode') +def make_new_typed_target(): + """ + >>> isinstance(make_new_typed_target(), MyType) + True + """ + cdef MyType m + m = MyType.__new__(MyType) + return m + @cython.test_assert_path_exists('//PythonCapiCallNode') @cython.test_fail_if_path_exists('//SimpleCallNode/AttributeNode') def make_new_builtin():