Skip to content

gh-146615: Fix format specifiers in Python/ directory#146619

Draft
sunmy2019 wants to merge 1 commit intopython:mainfrom
sunmy2019:gh-146615-3
Draft

gh-146615: Fix format specifiers in Python/ directory#146619
sunmy2019 wants to merge 1 commit intopython:mainfrom
sunmy2019:gh-146615-3

Conversation

@sunmy2019
Copy link
Copy Markdown
Member

@sunmy2019 sunmy2019 commented Mar 30, 2026

return;
_PyErr_Format(tstate, PyExc_TypeError,
"%U() missing %i required %s argument%s: %U",
"%U() missing %zi required %s argument%s: %U",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use %zd as more common spelling.

Py_ssize_t min = Py_MIN(pos, parser->min);
PyErr_Format(PyExc_TypeError,
"%.200s%s takes %s %d positional argument%s"
"%.200s%s takes %s %zd positional argument%s"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The right fix is to change the type of min to int.

keyword = PyTuple_GET_ITEM(kwtuple, i - pos);
PyErr_Format(PyExc_TypeError, "%.200s%s missing required "
"argument '%U' (pos %d)",
"argument '%U' (pos %zd)",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, the type of i should be int.

PyErr_Format(PyExc_TypeError,
"argument for %.200s%s given by name ('%U') "
"and position (%d)",
"and position (%zd)",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

@picnixz
Copy link
Copy Markdown
Member

picnixz commented Mar 30, 2026

See #146620 (comment) for the rationale of adding a skip news

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants