From: Robert Bradshaw Date: Tue, 28 Oct 2008 05:21:36 +0000 (-0700) Subject: String subtyping fix from Jason Evans X-Git-Tag: 0.9.9.2.beta~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=25027a8d0f29ca54b0ada94b06aafa0b737d545f;p=cython.git String subtyping fix from Jason Evans --- 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,