[New-bugs-announce] [issue31229] wrong error messages when too many kwargs are received
Oren Milman
report at bugs.python.org
Thu Aug 17 14:02:16 EDT 2017
New submission from Oren Milman:
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?
----------
components: Interpreter Core
messages: 300451
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: wrong error messages when too many kwargs are received
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31229>
_______________________________________
More information about the New-bugs-announce
mailing list