Commit 1eb59492 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Disallow <double*>obj (#313). Also removes warning for <void*>obj.

parent d125223d
......@@ -3937,6 +3937,8 @@ class TypecastNode(NewTempExprNode):
elif from_py and not to_py:
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:
error(self.pos, "Python objects can only be cast to void*")
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:
......
a = 3
cdef void* allowed = <void*>a
cdef double* disallowed = <double*>a
_ERRORS = u"""
5:26: Python objects can only be cast to void*
"""
# Ensure casting still works to void*
"""
>>> f()
('teststring', 'teststring')
"""
cdef extern from *:
ctypedef void PyObject
def f():
cdef void* p1
cdef PyObject* p2
a = "teststring"
p1 = <void*>a
p2 = <PyObject*>a
return (<object>p1, <object>p2)
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