From 6b043aa3d70c4c2e2aa144ad328907f542cdfb5d Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Thu, 14 May 2009 18:02:32 +0200 Subject: [PATCH] Testcase fix, update error message --- Cython/Compiler/ExprNodes.py | 2 +- tests/errors/e_tempcast.pyx | 7 ++++--- tests/errors/pyobjcastdisallow_T313.pyx | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index b0c7e7ac..f6e2b784 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -3939,7 +3939,7 @@ class TypecastNode(NewTempExprNode): if self.type.from_py_function: self.operand = self.operand.coerce_to(self.type, env) elif self.type.is_ptr and not (self.type.base_type.is_void or self.type.base_type.is_struct): - error(self.pos, "Python objects can only be cast to void*") + error(self.pos, "Python objects cannot be casted to pointers of primitive types") else: warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.type, self.operand.type)) elif from_py and to_py: diff --git a/tests/errors/e_tempcast.pyx b/tests/errors/e_tempcast.pyx index 7d80a121..4e59a41c 100644 --- a/tests/errors/e_tempcast.pyx +++ b/tests/errors/e_tempcast.pyx @@ -1,9 +1,10 @@ cdef object blarg def foo(obj): - cdef int *p - p = blarg # okay - p = (foo + blarg) # error - temporary + cdef void *p + p = blarg # ok + p = (obj + blarg) # error - temporary + _ERRORS = u""" 6:5: Casting temporary Python object to non-numeric non-Python type """ diff --git a/tests/errors/pyobjcastdisallow_T313.pyx b/tests/errors/pyobjcastdisallow_T313.pyx index 3d8ea1ce..18ca2b04 100644 --- a/tests/errors/pyobjcastdisallow_T313.pyx +++ b/tests/errors/pyobjcastdisallow_T313.pyx @@ -5,5 +5,5 @@ cdef void* allowed = a cdef double* disallowed = a _ERRORS = u""" -5:26: Python objects can only be cast to void* +5:26: Python objects cannot be casted to pointers of primitive types """ -- 2.26.2