Issue 31229: wrong error messages when too many kwargs are received (original) (raw)

Some functions produce wrong error messages in case they receive too many keyword arguments:

ISTM that changing these error messages to refer to 'keyword arguments' instead of 'arguments' is a possible solution. (e.g. the last one would become 'print() takes at most 4 keyword arguments (6 given)'

To do that, I changed two 'takes at most' PyErr_Format calls in Python/getargs.c. I ran the test suite, and it seems that this patch doesn't break anything. The diff file is attached. (I didn't open a PR before hearing your opinion, as ISTM that changing code in getargs.c is a delicate thing.)

what do you think?

I already wrote a patch, but I thought it would be better to wait until #31236 is resolved. this is because #31236 would change the error messages of min() and max(), and test_call tests exact error messages in CFunctionCallsErrorMessages, which is where I thought the tests of this issue should be added.