From b95b578935490d1993160247224f6a50c4e7916a Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 11 Feb 2009 13:11:50 -0800 Subject: [PATCH] fix size_t conversions --- Cython/Compiler/Nodes.py | 8 +++++--- Cython/Compiler/PyrexTypes.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 73525923..310bdb49 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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 diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 6022676b..0b1daceb 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -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") -- 2.26.2