This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: improve some error messages of min() and max()
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Oren Milman, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-08-18 21:51 by Oren Milman, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3146 merged Oren Milman, 2017-08-18 22:04
Messages (3)
msg300539 - (view) Author: Oren Milman (Oren Milman) * Date: 2017-08-18 21:51
currently, we have the following:
    >>> min(0, a=1)
    TypeError: 'a' is an invalid keyword argument for this function
    >>> max(0, a=1)
    TypeError: 'a' is an invalid keyword argument for this function
    >>> max(0, a=1, b=2, c=3)
    TypeError: function takes at most 2 arguments (3 given)
    >>> min(0, a=1, b=2, c=3)
    TypeError: function takes at most 2 arguments (3 given)

ISTM it would be preferable for min() and max() to have error messages similar
to those of int():
    >>> int(0, a=1)
    TypeError: 'a' is an invalid keyword argument for int()
    >>> int(0, a=1, b=2)
    TypeError: int() takes at most 2 arguments (3 given)

we can achieve this by making a small change in Python/bltinmodule.c in
min_max (I would open a PR soon), and by resolving #31229.
msg300565 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-08-19 04:32
LGTM.
msg300644 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-08-21 17:19
New changeset 58cf7488d5dcc8f47151d09fc1fa057b4dda563b by Serhiy Storchaka (Oren Milman) in branch 'master':
bpo-31236: Improved some error messages of min() and max().
https://github.com/python/cpython/commit/58cf7488d5dcc8f47151d09fc1fa057b4dda563b
History
Date User Action Args
2022-04-11 14:58:50adminsetgithub: 75419
2017-08-21 17:19:59serhiy.storchakasetstatus: open -> closed
dependencies: - wrong error messages when too many kwargs are received
resolution: fixed
stage: patch review -> resolved
2017-08-21 17:19:10serhiy.storchakasetmessages: + msg300644
2017-08-19 04:32:41serhiy.storchakasetdependencies: + wrong error messages when too many kwargs are received
type: behavior -> enhancement
components: + Interpreter Core, - IO

nosy: + serhiy.storchaka
messages: + msg300565
stage: patch review
2017-08-18 22:04:19Oren Milmansetpull_requests: + pull_request3181
2017-08-18 21:51:19Oren Milmancreate