10000 "ValueError: min() arg is an empty sequence" is wrong (builtins.min/max) · Issue #90829 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

"ValueError: min() arg is an empty sequence" is wrong (builtins.min/max) #90829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Nnarol mannequin opened this issue Feb 7, 2022 · 3 comments
Closed

"ValueError: min() arg is an empty sequence" is wrong (builtins.min/max) #90829

Nnarol mannequin opened this issue Feb 7, 2022 · 3 comments
Labels
3.12 only security fixes easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@Nnarol
Copy link
Mannequin
Nnarol mannequin commented Feb 7, 2022
BPO 46671
Nosy @Nnarol
PRs
  • GH-90829: Fix empty iterable error message in min/max #31181
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2022-02-07.00:22:26.157>
    labels = ['interpreter-core', 'type-bug', '3.11']
    title = '"ValueError: min() arg is an empty sequence" is wrong (builtins.min/max)'
    updated_at = <Date 2022-02-07.00:52:23.413>
    user = 'https://github.com/Nnarol'

    bugs.python.org fields:

    activity = <Date 2022-02-07.00:52:23.413>
    actor = 'Nnarol'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2022-02-07.00:22:26.157>
    creator = 'Nnarol'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46671
    keywords = ['patch']
    message_count = 1.0
    messages = ['412694']
    nosy_count = 1.0
    nosy_names = ['Nnarol']
    pr_nums = ['31181']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue46671'
    versions = ['Python 3.11']

    @Nnarol
    Copy link
    Mannequin Author
    Nnarol mannequin commented Feb 7, 2022

    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.

    @Nnarol Nnarol mannequin added stdlib Python modules in the Lib dir 3.11 only security fixes type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) and removed stdlib Python modules in the Lib dir labels Feb 7, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @SohamRatnaparkhi
    Copy link

    Hi, I want to solve this issue. How can I start? Thank you!

    @hauntsaninja
    Copy link
    Contributor

    This is currently being discussed in #31181 — explicitly linking because the PR predates the Github issues migration. In particular, we don't need more PRs addressing this issue.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.12 only security fixes easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants
    0