[Python-checkins] cpython (3.4): Issue #21892, #21893: Partial revert of changeset 4f55e802baf0, PyErr_Format()

victor.stinner python-checkins at python.org
Fri Jul 4 22:50:43 CEST 2014


http://hg.python.org/cpython/rev/6fb1e2ce513a
changeset:   91542:6fb1e2ce513a
branch:      3.4
parent:      91540:c76ab5f4fcc1
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Jul 04 22:47:46 2014 +0200
summary:
  Issue #21892, #21893: Partial revert of changeset 4f55e802baf0, PyErr_Format()
uses "%zd" for Py_ssize_t, not PY_FORMAT_SIZE_T

files:
  Objects/unicodeobject.c |  26 ++++++++------------------
  1 files changed, 8 insertions(+), 18 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1372,9 +1372,8 @@
     how_many = Py_MIN(PyUnicode_GET_LENGTH(from), how_many);
     if (to_start + how_many > PyUnicode_GET_LENGTH(to)) {
         PyErr_Format(PyExc_SystemError,
-                     "Cannot write %" PY_FORMAT_SIZE_T "i characters at %"
-                     PY_FORMAT_SIZE_T "i in a string of %"
-                     PY_FORMAT_SIZE_T "i characters",
+                     "Cannot write %zi characters at %zi "
+                     "in a string of %zi characters",
                      how_many, to_start, PyUnicode_GET_LENGTH(to));
         return -1;
     }
@@ -4083,9 +4082,7 @@
     if (newpos<0)
         newpos = insize+newpos;
     if (newpos<0 || newpos>insize) {
-        PyErr_Format(PyExc_IndexError,
-                     "position %" PY_FORMAT_SIZE_T
-                     "d from error handler out of bounds", newpos);
+        PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", newpos);
         goto onError;
     }
 
@@ -4178,9 +4175,7 @@
     if (newpos<0)
         newpos = insize+newpos;
     if (newpos<0 || newpos>insize) {
-        PyErr_Format(PyExc_IndexError,
-                     "position %" PY_FORMAT_SIZE_T
-                     "d from error handler out of bounds", newpos);
+        PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", newpos);
         goto onError;
     }
 
@@ -6443,9 +6438,7 @@
     if (*newpos<0)
         *newpos = len + *newpos;
     if (*newpos<0 || *newpos>len) {
-        PyErr_Format(PyExc_IndexError,
-                     "position %" PY_FORMAT_SIZE_T
-                     "d from error handler out of bounds", *newpos);
+        PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", *newpos);
         Py_DECREF(restuple);
         return NULL;
     }
@@ -8468,9 +8461,7 @@
     else
         *newpos = i_newpos;
     if (*newpos<0 || *newpos>PyUnicode_GET_LENGTH(unicode)) {
-        PyErr_Format(PyExc_IndexError,
-                     "position %" PY_FORMAT_SIZE_T
-                     "d from error handler out of bounds", *newpos);
+        PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", *newpos);
         Py_DECREF(restuple);
         return NULL;
     }
@@ -9752,8 +9743,7 @@
         item = items[i];
         if (!PyUnicode_Check(item)) {
             PyErr_Format(PyExc_TypeError,
-                         "sequence item %" PY_FORMAT_SIZE_T
-                         "d: expected str instance,"
+                         "sequence item %zd: expected str instance,"
                          " %.80s found",
                          i, Py_TYPE(item)->tp_name);
             goto onError;
@@ -14452,7 +14442,7 @@
     default:
         PyErr_Format(PyExc_ValueError,
                      "unsupported format character '%c' (0x%x) "
-                     "at index %" PY_FORMAT_SIZE_T "d",
+                     "at index %zd",
                      (31<=arg->ch && arg->ch<=126) ? (char)arg->ch : '?',
                      (int)arg->ch,
                      ctx->fmtpos - 1);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list