From 14f7508fe0623f28e0e33eef9e686b59da4dc884 Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Mon, 6 Apr 2009 16:31:47 -0300 Subject: [PATCH] use PY_FORMAT_SIZE_T to format Py_ssize_t values --- Cython/Compiler/ExprNodes.py | 2 +- Cython/Compiler/ModuleNode.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 12eed177..a57a680b 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -2135,7 +2135,7 @@ class SliceIndexNode(ExprNode): check = stop if check: code.putln("if (unlikely((%s) != %d)) {" % (check, target_size)) - code.putln('PyErr_Format(PyExc_ValueError, "Assignment to slice of wrong length, expected %%d, got %%d", %d, (%s));' % ( + code.putln('PyErr_Format(PyExc_ValueError, "Assignment to slice of wrong length, expected %%"PY_FORMAT_SIZE_T"d, got %%"PY_FORMAT_SIZE_T"d", (Py_ssize_t)%d, (Py_ssize_t)(%s));' % ( target_size, check)) code.putln(code.error_goto(self.pos)) code.putln("}") diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 01567912..5a09f89e 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -425,6 +425,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln(" typedef int Py_ssize_t;") code.putln(" #define PY_SSIZE_T_MAX INT_MAX") code.putln(" #define PY_SSIZE_T_MIN INT_MIN") + code.putln(" #define PY_FORMAT_SIZE_T \"\"") code.putln(" #define PyInt_FromSsize_t(z) PyInt_FromLong(z)") code.putln(" #define PyInt_AsSsize_t(o) PyInt_AsLong(o)") code.putln(" #define PyNumber_Index(o) PyNumber_Int(o)") -- 2.26.2