From: Stefan Behnel Date: Fri, 4 Dec 2009 11:08:14 +0000 (+0100) Subject: safety fix for ticket 461: prevent imported extension types from becoming spanning... X-Git-Tag: 0.12.1~92 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0c584f6928604f5833380650890b6d8a7f08bf65;p=cython.git safety fix for ticket 461: prevent imported extension types from becoming spanning types - use PyObject instead --- diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 3dab8abb..d54cd571 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -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