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:
--- /dev/null
+# 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)
+