Skip to content

Improve error message when passing an invalid producer to dict #135765

Open
@deanm0000

Description

@deanm0000

Bug report

Bug description:

dict("")
# {}
dict(" ")
ValueError: dictionary update sequence element #0 has length 1; 2 is required

I can see how an empty string might be intended to return an empty dict but since " " is raising an error about the 0th element needing a longer length it seems it isn't looking at the type of the input and an empty string works simply because its length is 0.

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions