Commit 25027a8d authored by Robert Bradshaw's avatar Robert Bradshaw

String subtyping fix from Jason Evans

parent 88ca3385
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment