From 21897347934b8edb36213e5b962a57c3175778d5 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw <robertwb@gmail.com> Date: Wed, 12 Oct 2011 22:42:27 -0700 Subject: [PATCH] Revert "Fix type inferance for constructors with keyword arguments." This commit seems to break the py3k build. This reverts commit b50c6792eb3e154fa8e4cefbd2c1fff8b8225a92. --- Cython/Compiler/ExprNodes.py | 42 ++++++++++++++++++------------------ tests/run/type_inference.pyx | 12 ----------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index d1ee54390..85b44b255 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -3232,27 +3232,6 @@ class CallNode(ExprNode): # allow overriding the default 'may_be_none' behaviour may_return_none = None - def infer_type(self, env): - function = self.function - func_type = function.infer_type(env) - if isinstance(self.function, NewExprNode): - return PyrexTypes.CPtrType(self.function.class_type) - if func_type.is_ptr: - func_type = func_type.base_type - if func_type.is_cfunction: - return func_type.return_type - elif func_type is type_type: - if function.is_name and function.entry and function.entry.type: - result_type = function.entry.type - if result_type.is_extension_type: - return result_type - elif result_type.is_builtin_type: - if function.entry.name == 'float': - return PyrexTypes.c_double_type - elif function.entry.name in Builtin.types_that_construct_their_instance: - return result_type - return py_object_type - def may_be_none(self): if self.may_return_none is not None: return self.may_return_none @@ -3330,6 +3309,27 @@ class SimpleCallNode(CallNode): # the case of function overloading. return self.function.type_dependencies(env) + def infer_type(self, env): + function = self.function + func_type = function.infer_type(env) + if isinstance(self.function, NewExprNode): + return PyrexTypes.CPtrType(self.function.class_type) + if func_type.is_ptr: + func_type = func_type.base_type + if func_type.is_cfunction: + return func_type.return_type + elif func_type is type_type: + if function.is_name and function.entry and function.entry.type: + result_type = function.entry.type + if result_type.is_extension_type: + return result_type + elif result_type.is_builtin_type: + if function.entry.name == 'float': + return PyrexTypes.c_double_type + elif function.entry.name in Builtin.types_that_construct_their_instance: + return result_type + return py_object_type + def analyse_as_type(self, env): attr = self.function.as_cython_attribute() if attr == 'pointer': diff --git a/tests/run/type_inference.pyx b/tests/run/type_inference.pyx index 1b088524f..61ec7c8e7 100644 --- a/tests/run/type_inference.pyx +++ b/tests/run/type_inference.pyx @@ -513,18 +513,6 @@ def common_extension_type_base(): w = CC() assert typeof(w) == "Python object", typeof(w) -cdef class AcceptsKeywords: - def __init__(self, *args, **kwds): - pass - -@infer_types(None) -def constructor_call(): - """ - >>> constructor_call() - """ - x = AcceptsKeywords(a=1, b=2) - assert typeof(x) == "AcceptsKeywords", typeof(x) - @infer_types(None) def large_literals(): -- 2.30.9