safety fix for ticket 461: prevent imported extension types from becoming spanning...
authorStefan Behnel <scoder@users.berlios.de>
Fri, 4 Dec 2009 11:08:14 +0000 (12:08 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 4 Dec 2009 11:08:14 +0000 (12:08 +0100)
Cython/Compiler/PyrexTypes.py

index 3dab8abbf5d04c9f515a485e46dc5c5bbb74810e..d54cd5710b723b1d454f695fc9f2665d0d7d76fe 100644 (file)
@@ -2030,8 +2030,15 @@ def spanning_type(type1, type2):
     elif type1.is_pyobject ^ type2.is_pyobject:
         return py_object_type
     elif type1.assignable_from(type2):
+        if type1.is_extension_type and type1.typeobj_is_imported():
+            # external types are unsafe, so we use PyObject instead
+            return py_object_type
         return type1
-    elif type2.assignable_from(type1):
+    elif type2.assignable_from(type1) and \
+             not (type2.is_typedef and type2.typedef_is_external):
+        if type2.is_extension_type and type2.typeobj_is_imported():
+            # external types are unsafe, so we use PyObject instead
+            return py_object_type
         return type2
     else:
         return py_object_type