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: "ValueError: min() arg is an empty sequence" is wrong (builtins.min/max)
Type: behavior Stage: patch review
Components: Interpreter Core Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Nnarol
Priority: normal Keywords: patch

Created on 2022-02-07 00:22 by Nnarol, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 31181 open Nnarol, 2022-02-07 00:35
Messages (1)
msg412694 - (view) Author: Nnarol (Nnarol) * Date: 2022-02-07 00:22
Incorrect error message by min_max(): "ValueError: min() arg is an empty sequence" when using the form

    min(iterable, *[, default=obj, key=func]) -> value

and "iterable" is empty, like so:

    min([])

or:

    min(set())

"Sequence" is referred to, even though the function accepts any iterable. E.g. if a different type of collection, such as a set was provided by the user, "sequence" is still printed.

I propose to rephrase the error to "iterable argument is empty", to reflect actual behavior and be in line with the function's documented interface.

"arg" also does not name either any specific variable in C code or a parameter in user-facing documentation. Such an abbreviation is not used by the function's other error messages either, which simply write "argument" or "arguments" in free text, as appropriate in the given context.

Unlike for the error "max expected at least 1 argument, got 0", the above scenario's test does not include matching of the error string. This is probably the reason this was not noticed before. It would be nice to make the test more specific.

The issue seems trivial, but I am not familiar with the CPython project's policy on whether to treat messages of errors, printed on stderr as an interface, in which case, the change would be backwards-incompatible.
Definitely a decision to be made.
History
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90829
2022-02-07 00:52:23Nnarolsetcomponents: + Interpreter Core, - Library (Lib)
2022-02-07 00:35:09Nnarolsetkeywords: + patch
stage: patch review
pull_requests: + pull_request29352
2022-02-07 00:22:26Nnarolcreate