From: Robert Bradshaw Date: Wed, 10 Feb 2010 23:31:55 +0000 (-0800) Subject: More safe types to infer. X-Git-Tag: 0.13.beta0~340^2~27 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e2937fcb275842fe8b152a600dfd8aec90a431fc;p=cython.git More safe types to infer. --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 1c04e93e..b7023ab8 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -2492,6 +2492,8 @@ class SimpleCallNode(CallNode): 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: diff --git a/Cython/Compiler/TypeInference.py b/Cython/Compiler/TypeInference.py index d7089d57..72d389c8 100644 --- a/Cython/Compiler/TypeInference.py +++ b/Cython/Compiler/TypeInference.py @@ -235,6 +235,20 @@ def safe_spanning_type(types): # find_spanning_type() only returns 'bint' for clean boolean # operations without other int types, so this is safe, too return result_type + elif result_type.is_ptr and not (result_type.is_int and result_type.rank == 0): + # Any pointer except (signed|unsigned|) char* can't implicitly + # become a PyObject. + return result_type + elif result_type.is_cpp_class: + # These can't implicitly become Python objects either. + return result_type + elif result_type.is_struct: + # Though we have struct -> object for some structs, this is uncommonly + # used, won't arise in pure Python, and there shouldn't be side + # effects, so I'm declaring this safe. + return result_type + # TODO: double complex should be OK as well, but we need + # to make sure everything is supported. return py_object_type