use PY_FORMAT_SIZE_T to format Py_ssize_t values
authorLisandro Dalcin <dalcinl@gmail.com>
Mon, 6 Apr 2009 19:31:47 +0000 (16:31 -0300)
committerLisandro Dalcin <dalcinl@gmail.com>
Mon, 6 Apr 2009 19:31:47 +0000 (16:31 -0300)
Cython/Compiler/ExprNodes.py
Cython/Compiler/ModuleNode.py

index 12eed177d6e4087ce2f48f960773bb7faa67d19a..a57a680bac34826229aaec6600b00d6b63fd2a2d 100644 (file)
@@ -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("}")
index 01567912f77c2dc0f81416cf92084f134b190686..5a09f89ed641d554f6e3274b9dc18eddfbfd5143 100644 (file)
@@ -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)")