From 405ec48459a29d80df0a85a4fa60dc5cdb5355f3 Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Thu, 14 May 2009 17:46:40 +0200 Subject: [PATCH] Attempt to fix disappearence of conversion errors (introduced by b8850487f853) --- Cython/Compiler/ExprNodes.py | 4 ++-- Cython/Compiler/PyrexTypes.py | 4 ++-- tests/errors/e_ass.pyx | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index fc608b1d..b0c7e7ac 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -5177,7 +5177,7 @@ class CoerceToPyTypeNode(CoercionNode): self.type = py_object_type self.gil_check(env) self.is_temp = 1 - if not arg.type.to_py_function or not arg.type.create_to_py_utility_code(env): + if not arg.type.create_to_py_utility_code(env): error(arg.pos, "Cannot convert '%s' to Python object" % arg.type) @@ -5215,7 +5215,7 @@ class CoerceFromPyTypeNode(CoercionNode): CoercionNode.__init__(self, arg) self.type = result_type self.is_temp = 1 - if not result_type.from_py_function and not result_type.create_from_py_utility_code(env): + if not result_type.create_from_py_utility_code(env): error(arg.pos, "Cannot convert Python object to '%s'" % result_type) if self.type.is_string and self.arg.is_ephemeral(): diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 57c20341..17e4cf59 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -445,10 +445,10 @@ class CType(PyrexType): exception_check = 1 def create_to_py_utility_code(self, env): - return True + return self.to_py_function is not None def create_from_py_utility_code(self, env): - return True + return self.from_py_function is not None def error_condition(self, result_code): conds = [] diff --git a/tests/errors/e_ass.pyx b/tests/errors/e_ass.pyx index 10b11c30..a49015db 100644 --- a/tests/errors/e_ass.pyx +++ b/tests/errors/e_ass.pyx @@ -4,7 +4,11 @@ cdef void foo(obj): cdef int *p2 i1 = p1 # error p2 = obj # error + + obj = p2 # error + _ERRORS = u""" 5:16: Cannot assign type 'char *' to 'int' 6:17: Cannot convert Python object to 'int *' +8:17: Cannot convert 'int *' to Python object """ -- 2.26.2