Commit 6b043aa3 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Testcase fix, update error message

parent 405ec484
...@@ -3939,7 +3939,7 @@ class TypecastNode(NewTempExprNode): ...@@ -3939,7 +3939,7 @@ class TypecastNode(NewTempExprNode):
if self.type.from_py_function: if self.type.from_py_function:
self.operand = self.operand.coerce_to(self.type, env) 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): 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: else:
warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.type, self.operand.type)) warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.type, self.operand.type))
elif from_py and to_py: elif from_py and to_py:
......
cdef object blarg cdef object blarg
def foo(obj): def foo(obj):
cdef int *p cdef void *p
p = <int *>blarg # okay p = <void *>blarg # ok
p = <int *>(foo + blarg) # error - temporary p = <void *>(obj + blarg) # error - temporary
_ERRORS = u""" _ERRORS = u"""
6:5: Casting temporary Python object to non-numeric non-Python type 6:5: Casting temporary Python object to non-numeric non-Python type
""" """
...@@ -5,5 +5,5 @@ cdef void* allowed = <void*>a ...@@ -5,5 +5,5 @@ cdef void* allowed = <void*>a
cdef double* disallowed = <double*>a cdef double* disallowed = <double*>a
_ERRORS = u""" _ERRORS = u"""
5:26: Python objects can only be cast to void* 5:26: Python objects cannot be casted to pointers of primitive types
""" """
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