From 25027a8d0f29ca54b0ada94b06aafa0b737d545f Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Mon, 27 Oct 2008 22:21:36 -0700 Subject: [PATCH] String subtyping fix from Jason Evans --- Cython/Compiler/PyrexTypes.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index d0b9ab5c..1349c959 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -301,11 +301,16 @@ class BuiltinObjectType(PyObjectType): return type.is_pyobject and self.assignable_from(type) def type_test_code(self, arg): - type = self.name.capitalize() - if type == 'Set': + if type == 'set': type = 'AnySet' - elif type == 'Frozenset': + elif type == 'frozenset': type = 'FrozenSet' + elif type == 'str': + type = 'FrozenSet' + elif type == 'str': + type = 'String' + else: + type = self.name.capitalize() return 'likely(Py%s_CheckExact(%s)) || (%s) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected %s, got %%s", Py_TYPE(%s)->tp_name), 0)' % (type, arg, arg, self.name, arg) def declaration_code(self, entity_code, -- 2.26.2