fix C assignment issue for the typed target case
authorStefan Behnel <scoder@users.berlios.de>
Sat, 31 Oct 2009 14:35:48 +0000 (15:35 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sat, 31 Oct 2009 14:35:48 +0000 (15:35 +0100)
Cython/Compiler/Optimize.py
tests/run/tp_new.pyx

index 44a9cda0353bb9e932c8530d1138f1592f383c12..c8258ef4e17fc7b5e38ed15eb57cf54675d9f1df 100644 (file)
@@ -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:
index d176fc3b3781c304cf7aa58a7a2e69cfae09f5ab..01f068278e7e6598c6b41991830cca113430c8e0 100644 (file)
@@ -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():