cython-devel

changeset 1802:fa0111c401cc

fix ticket #227: type check for bool is called PyBool_Check, not CheckExact
author Stefan Behnel <scoder@users.berlios.de>
date Sun Mar 01 20:59:01 2009 +0100 (2 years ago)
parents 3e08dec3cdd0
children 32777658ca58
files Cython/Compiler/PyrexTypes.py
line diff
1.1 --- a/Cython/Compiler/PyrexTypes.py Sun Mar 01 20:50:15 2009 +0100 1.2 +++ b/Cython/Compiler/PyrexTypes.py Sun Mar 01 20:59:01 2009 +0100 1.3 @@ -303,14 +303,16 @@ 1.4 def type_test_code(self, arg): 1.5 type_name = self.name 1.6 if type_name == 'str': 1.7 - type_name = 'String' 1.8 + check = 'PyString_CheckExact' 1.9 elif type_name == 'set': 1.10 - type_name = 'AnySet' 1.11 + check = 'PyAnySet_CheckExact' 1.12 elif type_name == 'frozenset': 1.13 - type_name = 'FrozenSet' 1.14 + check = 'PyFrozenSet_CheckExact' 1.15 + elif type_name == 'bool': 1.16 + check = 'PyBool_Check' 1.17 else: 1.18 - type_name = type_name.capitalize() 1.19 - 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) 1.20 + check = 'Py%s_CheckExact' % type_name.capitalize() 1.21 + 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) 1.22 1.23 def declaration_code(self, entity_code, 1.24 for_display = 0, dll_linkage = None, pyrex = 0):