Commit da1acf30 authored by Stefan Behnel's avatar Stefan Behnel

fix C assignment issue for the typed target case

parent ac3536e9
...@@ -756,7 +756,9 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): ...@@ -756,7 +756,9 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
### cleanup to avoid redundant coercions to/from Python types ### 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. """Flatten redundant type checks after tree changes.
""" """
old_arg = node.arg old_arg = node.arg
...@@ -1073,7 +1075,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): ...@@ -1073,7 +1075,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
# of the extension type and call that instead of the generic slot # of the extension type and call that instead of the generic slot
func_type = PyrexTypes.CFuncType( func_type = PyrexTypes.CFuncType(
return_type, [ return_type, [
PyrexTypes.CFuncTypeArg("type", PyrexTypes.py_object_type, None) PyrexTypes.CFuncTypeArg("type", Builtin.type_type, None)
]) ])
if not type_arg.type_entry: if not type_arg.type_entry:
......
...@@ -29,6 +29,17 @@ def make_new(): ...@@ -29,6 +29,17 @@ def make_new():
m = MyType.__new__(MyType) m = MyType.__new__(MyType)
return m 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_assert_path_exists('//PythonCapiCallNode')
@cython.test_fail_if_path_exists('//SimpleCallNode/AttributeNode') @cython.test_fail_if_path_exists('//SimpleCallNode/AttributeNode')
def make_new_builtin(): def make_new_builtin():
......
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