Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a33bce0

Browse files
committed
Issue #21892, #21893: Partial revert of changeset 4f55e802baf0, PyErr_Format()
uses "%zd" for Py_ssize_t, not PY_FORMAT_SIZE_T
1 parent 3410af4 commit a33bce0

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

Objects/unicodeobject.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,9 +1372,8 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
13721372
how_many = Py_MIN(PyUnicode_GET_LENGTH(from), how_many);
13731373
if (to_start + how_many > PyUnicode_GET_LENGTH(to)) {
13741374
PyErr_Format(PyExc_SystemError,
1375-
"Cannot write %" PY_FORMAT_SIZE_T "i characters at %"
1376-
PY_FORMAT_SIZE_T "i in a string of %"
1377-
PY_FORMAT_SIZE_T "i characters",
1375+
"Cannot write %zi characters at %zi "
1376+
"in a string of %zi characters",
13781377
how_many, to_start, PyUnicode_GET_LENGTH(to));
13791378
return -1;
13801379
}
@@ -4083,9 +4082,7 @@ unicode_decode_call_errorhandler_wchar(
40834082
if (newpos<0)
40844083
newpos = insize+newpos;
40854084
if (newpos<0 || newpos>insize) {
4086-
PyErr_Format(PyExc_IndexError,
4087-
"position %" PY_FORMAT_SIZE_T
4088-
"d from error handler out of bounds", newpos);
4085+
PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", newpos);
40894086
goto onError;
40904087
}
40914088

@@ -4178,9 +4175,7 @@ unicode_decode_call_errorhandler_writer(
41784175
if (newpos<0)
41794176
newpos = insize+newpos;
41804177
if (newpos<0 || newpos>insize) {
4181-
PyErr_Format(PyExc_IndexError,
4182-
"position %" PY_FORMAT_SIZE_T
4183-
"d from error handler out of bounds", newpos);
4178+
PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", newpos);
41844179
goto onError;
41854180
}
41864181

@@ -6443,9 +6438,7 @@ unicode_encode_call_errorhandler(const char *errors,
64436438
if (*newpos<0)
64446439
*newpos = len + *newpos;
64456440
if (*newpos<0 || *newpos>len) {
6446-
PyErr_Format(PyExc_IndexError,
6447-
"position %" PY_FORMAT_SIZE_T
6448-
"d from error handler out of bounds", *newpos);
6441+
PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", *newpos);
64496442
Py_DECREF(restuple);
64506443
return NULL;
64516444
}
@@ -8468,9 +8461,7 @@ unicode_translate_call_errorhandler(const char *errors,
84688461
else
84698462
*newpos = i_newpos;
84708463
if (*newpos<0 || *newpos>PyUnicode_GET_LENGTH(unicode)) {
8471-
PyErr_Format(PyExc_IndexError,
8472-
"position %" PY_FORMAT_SIZE_T
8473-
"d from error handler out of bounds", *newpos);
8464+
PyErr_Format(PyExc_IndexError, "position %zd from error handler out of bounds", *newpos);
84748465
Py_DECREF(restuple);
84758466
return NULL;
84768467
}
@@ -9752,8 +9743,7 @@ PyUnicode_Join(PyObject *separator, PyObject *seq)
97529743
item = items[i];
97539744
if (!PyUnicode_Check(item)) {
97549745
PyErr_Format(PyExc_TypeError,
9755-
"sequence item %" PY_FORMAT_SIZE_T
9756-
"d: expected str instance,"
9746+
"sequence item %zd: expected str instance,"
97579747
" %.80s found",
97589748
i, Py_TYPE(item)->tp_name);
97599749
goto onError;
@@ -14452,7 +14442,7 @@ unicode_format_arg_format(struct unicode_formatter_t *ctx,
1445214442
default:
1445314443
PyErr_Format(PyExc_ValueError,
1445414444
"unsupported format character '%c' (0x%x) "
14455-
"at index %" PY_FORMAT_SIZE_T "d",
14445+
"at index %zd",
1445614446
(31<=arg->ch && arg->ch<=126) ? (char)arg->ch : '?',
1445714447
(int)arg->ch,
1445814448
ctx->fmtpos - 1);

0 commit comments

Comments
 (0)