mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
bpo-36254: Fix invalid uses of %d in format strings in C. (GH-12264)
This commit is contained in:
parent
10f8ce6688
commit
d53fe5f407
20 changed files with 35 additions and 35 deletions
|
@ -372,14 +372,14 @@ vgetargs1_impl(PyObject *compat_args, PyObject *const *stack, Py_ssize_t nargs,
|
|||
if (nargs < min || max < nargs) {
|
||||
if (message == NULL)
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.150s%s takes %s %d argument%s (%ld given)",
|
||||
"%.150s%s takes %s %d argument%s (%zd given)",
|
||||
fname==NULL ? "function" : fname,
|
||||
fname==NULL ? "" : "()",
|
||||
min==max ? "exactly"
|
||||
: nargs < min ? "at least" : "at most",
|
||||
nargs < min ? min : max,
|
||||
(nargs < min ? min : max) == 1 ? "" : "s",
|
||||
Py_SAFE_DOWNCAST(nargs, Py_ssize_t, long));
|
||||
nargs);
|
||||
else
|
||||
PyErr_SetString(PyExc_TypeError, message);
|
||||
return cleanreturn(0, &freelist);
|
||||
|
@ -1741,7 +1741,7 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
|
|||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s%s takes %s %d positional argument%s"
|
||||
" (%d given)",
|
||||
" (%zd given)",
|
||||
(fname == NULL) ? "function" : fname,
|
||||
(fname == NULL) ? "" : "()",
|
||||
(min != INT_MAX) ? "at most" : "exactly",
|
||||
|
@ -1826,7 +1826,7 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
|
|||
if (skip) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s%s takes %s %d positional argument%s"
|
||||
" (%d given)",
|
||||
" (%zd given)",
|
||||
(fname == NULL) ? "function" : fname,
|
||||
(fname == NULL) ? "" : "()",
|
||||
(Py_MIN(pos, min) < i) ? "at least" : "exactly",
|
||||
|
@ -2194,7 +2194,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
|
|||
Py_ssize_t min = Py_MIN(pos, parser->min);
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s%s takes %s %d positional argument%s"
|
||||
" (%d given)",
|
||||
" (%zd given)",
|
||||
(parser->fname == NULL) ? "function" : parser->fname,
|
||||
(parser->fname == NULL) ? "" : "()",
|
||||
min < parser->max ? "at least" : "exactly",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue