Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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