Message300451
Some functions produce wrong error messages in case they receive too many
keyword arguments:
- in Objects/exceptions.c - ImportError_init:
>>> ImportError(1, 2, 3, 4, a=5, b=6, c=7)
TypeError: ImportError() takes at most 2 arguments (3 given)
- in Python/bltinmodule.c - min_max:
>>> min(1, 2, 3, 4, a=5, b=6, c=7)
TypeError: function takes at most 2 arguments (3 given)
>>> max(1, 2, 3, 4, a=5, b=6, c=7)
TypeError: function takes at most 2 arguments (3 given)
- in Modules/itertoolsmodule.c - product_new:
>>> itertools.product(0, a=1, b=2, c=3, d=4, e=5, f=6)
TypeError: product() takes at most 1 argument (6 given)
- in Python/bltinmodule.c - builtin_print:
>>> print(0, a=1, b=2, c=3, d=4, e=5, f=6)
TypeError: print() takes at most 4 arguments (6 given)
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? |
|
Date |
User |
Action |
Args |
2017-08-17 18:02:16 | Oren Milman | set | recipients:
+ Oren Milman |
2017-08-17 18:02:16 | Oren Milman | set | messageid: <1502992936.21.0.653436354644.issue31229@psf.upfronthosting.co.za> |
2017-08-17 18:02:16 | Oren Milman | link | issue31229 messages |
2017-08-17 18:02:15 | Oren Milman | create | |
|