String subtyping fix from Jason Evans
authorRobert Bradshaw <robertwb@math.washington.edu>
Tue, 28 Oct 2008 05:21:36 +0000 (22:21 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Tue, 28 Oct 2008 05:21:36 +0000 (22:21 -0700)
Cython/Compiler/PyrexTypes.py

index d0b9ab5c8e73642593334d653880aae702d8cbf0..1349c9595e592c02dc8167b3c9f7b6cd229acd79 100644 (file)
@@ -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,