Allow <MyStruct*>obj as well; as there is no canonical PyObject
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Thu, 14 May 2009 15:09:39 +0000 (17:09 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Thu, 14 May 2009 15:09:39 +0000 (17:09 +0200)
Cython/Compiler/ExprNodes.py

index 77bfd9049c92782da22582ecb407d4ea1398ee83..55b7ef85be4e7a2c92d26a902e07c75acf23268f 100644 (file)
@@ -3939,7 +3939,8 @@ class TypecastNode(NewTempExprNode):
             if self.type.from_py_function:
                 self.operand = self.operand.coerce_to(self.type, env)
             elif self.type.is_ptr:
-                if not self.type.base_type.is_void:
+                base_type = self.type.base_type
+                if not base_type.is_void and not base_type.is_struct:
                     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))