(Merge 3.4) Issue #21892, #21893: Partial revert of changeset 4f55e802baf0,

PyErr_Format() uses "%zd" for Py_ssize_t, not PY_FORMAT_SIZE_T
This commit is contained in:
Victor Stinner 2014-07-04 22:50:13 +02:00
commit c68b7fba86
1 changed files with 8 additions and 18 deletions

View File

@ -1372,9 +1372,8 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
how_many = Py_MIN(PyUnicode_GET_LENGTH(from), how_many); how_many = Py_MIN(PyUnicode_GET_LENGTH(from), how_many);
if (to_start + how_many > PyUnicode_GET_LENGTH(to)) { if (to_start + how_many > PyUnicode_GET_LENGTH(to)) {
PyErr_Format(PyExc_SystemError, PyErr_Format(PyExc_SystemError,
"Cannot write %" PY_FORMAT_SIZE_T "i characters at %" "Cannot write %zi characters at %zi "
PY_FORMAT_SIZE_T "i in a string of %" "in a string of %zi characters",
PY_FORMAT_SIZE_T "i characters",
how_many, to_start, PyUnicode_GET_LENGTH(to)); how_many, to_start, PyUnicode_GET_LENGTH(to));
return -1; return -1;
} }
@ -4083,9 +4082,7 @@ unicode_decode_call_errorhandler_wchar(
if (newpos<0) if (newpos<0)
newpos = insize+newpos; newpos = insize+newpos;
if (newpos<0 || newpos>insize) { if (newpos<0 || newpos>insize) {
PyErr_Format(PyExc_IndexError, PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", newpos);
"position %" PY_FORMAT_SIZE_T
"d from error handler out of bounds", newpos);
goto onError; goto onError;
} }
@ -4178,9 +4175,7 @@ unicode_decode_call_errorhandler_writer(
if (newpos<0) if (newpos<0)
newpos = insize+newpos; newpos = insize+newpos;
if (newpos<0 || newpos>insize) { if (newpos<0 || newpos>insize) {
PyErr_Format(PyExc_IndexError, PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", newpos);
"position %" PY_FORMAT_SIZE_T
"d from error handler out of bounds", newpos);
goto onError; goto onError;
} }
@ -6443,9 +6438,7 @@ unicode_encode_call_errorhandler(const char *errors,
if (*newpos<0) if (*newpos<0)
*newpos = len + *newpos; *newpos = len + *newpos;
if (*newpos<0 || *newpos>len) { if (*newpos<0 || *newpos>len) {
PyErr_Format(PyExc_IndexError, PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", *newpos);
"position %" PY_FORMAT_SIZE_T
"d from error handler out of bounds", *newpos);
Py_DECREF(restuple); Py_DECREF(restuple);
return NULL; return NULL;
} }
@ -8445,9 +8438,7 @@ unicode_translate_call_errorhandler(const char *errors,
else else
*newpos = i_newpos; *newpos = i_newpos;
if (*newpos<0 || *newpos>PyUnicode_GET_LENGTH(unicode)) { if (*newpos<0 || *newpos>PyUnicode_GET_LENGTH(unicode)) {
PyErr_Format(PyExc_IndexError, PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", *newpos);
"position %" PY_FORMAT_SIZE_T
"d from error handler out of bounds", *newpos);
Py_DECREF(restuple); Py_DECREF(restuple);
return NULL; return NULL;
} }
@ -9775,8 +9766,7 @@ PyUnicode_Join(PyObject *separator, PyObject *seq)
item = items[i]; item = items[i];
if (!PyUnicode_Check(item)) { if (!PyUnicode_Check(item)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"sequence item %" PY_FORMAT_SIZE_T "sequence item %zd: expected str instance,"
"d: expected str instance,"
" %.80s found", " %.80s found",
i, Py_TYPE(item)->tp_name); i, Py_TYPE(item)->tp_name);
goto onError; goto onError;
@ -14466,7 +14456,7 @@ unicode_format_arg_format(struct unicode_formatter_t *ctx,
default: default:
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"unsupported format character '%c' (0x%x) " "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 : '?', (31<=arg->ch && arg->ch<=126) ? (char)arg->ch : '?',
(int)arg->ch, (int)arg->ch,
ctx->fmtpos - 1); ctx->fmtpos - 1);