Skip to content

frozendict's hash is not initialised when created through pipe operator #149676

@KowalskiThomas

Description

@KowalskiThomas

Bug report

Bug description:

As far as I know, the expectation is a == b => hash(a) == hash(b), but currently, the following code fails:

a = frozendict({"a": 1})
b = frozendict({"b": 2})

c = frozendict({"a": 1, "b": 2})
c_union = a | b

assert c == c_union
assert hash(c) == hash(c_union)

with

  File "t.py", line 8, in <module>
    assert hash(c) == hash(c_union)
           ^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

I have a fix ready in #149675.

CPython versions tested on:

3.15

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions