From: Stefan Behnel Date: Sun, 1 Mar 2009 19:59:01 +0000 (+0100) Subject: fix ticket #227: type check for bool is called PyBool_Check, not CheckExact X-Git-Tag: 0.11.rc~12^2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d944e557c8067706a0ff6e5c3c7c4672abdcbb1c;p=cython.git fix ticket #227: type check for bool is called PyBool_Check, not CheckExact --- diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index aeea3c50..74745a14 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -303,14 +303,16 @@ class BuiltinObjectType(PyObjectType): def type_test_code(self, arg): type_name = self.name if type_name == 'str': - type_name = 'String' + check = 'PyString_CheckExact' elif type_name == 'set': - type_name = 'AnySet' + check = 'PyAnySet_CheckExact' elif type_name == 'frozenset': - type_name = 'FrozenSet' + check = 'PyFrozenSet_CheckExact' + elif type_name == 'bool': + check = 'PyBool_Check' else: - type_name = type_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_name, arg, arg, self.name, arg) + check = 'Py%s_CheckExact' % type_name.capitalize() + return 'likely(%s(%s)) || (%s) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected %s, got %%s", Py_TYPE(%s)->tp_name), 0)' % (check, arg, arg, self.name, arg) def declaration_code(self, entity_code, for_display = 0, dll_linkage = None, pyrex = 0):