Skip to content
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

frozenset.__hash__ vs. Set._hash #88870

Closed
Prometheus3375 mannequin opened this issue Jul 21, 2021 · 5 comments
Closed

frozenset.__hash__ vs. Set._hash #88870

Prometheus3375 mannequin opened this issue Jul 21, 2021 · 5 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Prometheus3375
Copy link
Mannequin

Prometheus3375 mannequin commented Jul 21, 2021

BPO 44704
Nosy @rhettinger, @miss-islington, @sweeneyde, @Prometheus3375
PRs
  • bpo-44704: Make Set._hash consistent with frozenset.__hash__ #27281
  • [3.10] bpo-44704: Make Set._hash consistent with frozenset.__hash__ (GH-27281) #27282
  • [3.9] bpo-44704: Make Set._hash consistent with frozenset.__hash__ (GH-27281) #27283
  • 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 = <Date 2021-07-21.23:59:44.967>
    created_at = <Date 2021-07-21.21:32:14.420>
    labels = ['type-bug', 'library', '3.9']
    title = 'frozenset.__hash__ vs. Set._hash'
    updated_at = <Date 2021-07-22.00:23:47.837>
    user = 'https://github.com/Prometheus3375'

    bugs.python.org fields:

    activity = <Date 2021-07-22.00:23:47.837>
    actor = 'rhettinger'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-07-21.23:59:44.967>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2021-07-21.21:32:14.420>
    creator = 'Prometheus3375'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44704
    keywords = ['patch']
    message_count = 4.0
    messages = ['397963', '397968', '397970', '397972', '397973']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'miss-islington', 'Dennis Sweeney', 'Prometheus3375']
    pr_nums = ['27281', '27282', '27283']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44704'
    versions = ['Python 3.9']

    @Prometheus3375
    Copy link
    Mannequin Author

    Prometheus3375 mannequin commented Jul 21, 2021

    In docstring of Set._hash in _collections_abc.py is written:
    "We match the algorithm used by the built-in frozenset type."

    But
    >>> s = frozenset({i for i in range(10)})
    >>> hash(s)
    3895031357313128696
    >>> Set._hash(s)
    3914343279946282847

    Looks like Set._hash is different.

    @Prometheus3375 Prometheus3375 mannequin added 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jul 21, 2021
    @sweeneyde
    Copy link
    Member

    I opened a PR. It looks like frozenset.__hash__ changed in #49444 and #49485, but Set._hash wasn't updated accordingly.

    @rhettinger
    Copy link
    Contributor

    New changeset c878f5d by Dennis Sweeney in branch 'main':
    bpo-44704: Make Set._hash consistent with frozenset.__hash__ (GH-27281)
    c878f5d

    @rhettinger
    Copy link
    Contributor

    New changeset e0ef816 by Miss Islington (bot) in branch '3.9':
    bpo-44704: Make Set._hash consistent with frozenset.__hash__ (GH-27281) (GH-27283)
    e0ef816

    @rhettinger
    Copy link
    Contributor

    New changeset 4194f14 by Miss Islington (bot) in branch '3.10':
    bpo-44704: Make Set._hash consistent with frozenset.__hash__ (GH-27281) (GH-27282)
    4194f14

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants