fix size_t conversions
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 11 Feb 2009 21:11:50 +0000 (13:11 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 11 Feb 2009 21:11:50 +0000 (13:11 -0800)
Cython/Compiler/Nodes.py
Cython/Compiler/PyrexTypes.py

index 73525923d4233e01d0ad31a4a7812c59405be033..310bdb49a24ad8166a3070ac2f4baa4ec27f37c5 100644 (file)
@@ -1725,9 +1725,11 @@ class DefNode(FuncDefNode):
                         (arg.type.is_extension_type or arg.type.is_builtin_type):
                     arg.needs_type_test = 1
                     any_type_tests_needed = 1
-                elif arg.type is PyrexTypes.c_py_ssize_t_type:
-                    # Want to use __index__ rather than __int__ method
-                    # that PyArg_ParseTupleAndKeywords calls
+                elif (arg.type is PyrexTypes.c_py_ssize_t_type
+                        or arg.type is PyrexTypes.c_size_t_type):
+                    # Don't use PyArg_ParseTupleAndKeywords's parsing
+                    # Py_ssize_t: want to use __index__ rather than __int__
+                    # size_t: no Python format char
                     arg.needs_conversion = 1
                     arg.hdr_type = PyrexTypes.py_object_type
                     arg.hdr_cname = Naming.arg_prefix + arg.name
index 6022676bf0c346602e998ced2480468bd911def1..0b1daceb5764e46da0f35176c8b5c8509cb2dee1 100644 (file)
@@ -1191,7 +1191,7 @@ c_slong_type =       CIntType(3, 2, "T_LONG")
 c_slonglong_type =   CLongLongType(4, 2, "T_LONGLONG")
 
 c_py_ssize_t_type =  CPySSizeTType(5, 1)
-c_size_t_type =      CSizeTType(6, 1)
+c_size_t_type =      CSizeTType(6, 1, "(sizeof(size_t) == sizeof(unsigned long) ? T_ULONG : T_ULONGLONG)")
 
 c_float_type =       CFloatType(7, "T_FLOAT")
 c_double_type =      CFloatType(8, "T_DOUBLE")