From 0c584f6928604f5833380650890b6d8a7f08bf65 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 4 Dec 2009 12:08:14 +0100 Subject: [PATCH] safety fix for ticket 461: prevent imported extension types from becoming spanning types - use PyObject instead --- Cython/Compiler/PyrexTypes.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.26.2