Skip to content

Unexpected behaviour when unpacking the outputs of a function returning a dictionary #146321

@LucaGherardini

Description

@LucaGherardini

Bug report

Bug description:

# Add a code block here, if required
def rec():
    return {'a': 1}

r, *_ = rec()
# r only contains 'a'
print(r)

r = rec()
# r is the full dictionary
print(r)

def rec():
    return {'a': 1}, None

r, *_ = rec()
# r is the full dictionary
print(r)

# expected behaviour: that r contains the full dictionary even when the unpacking operator (*_) is used, without the need to add an additional output 

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions