GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `typing._UnionGenericAlias` is unhashable in 3.14 · Issue #133925 · python/cpython

typing._UnionGenericAlias is unhashable in 3.14 #133925

New issue
Copy link
New issue
Copy link
Closed
Closed
typing._UnionGenericAlias is unhashable in 3.14#133925
Copy link
Labels
topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@neutrinoceros
neutrinoceros
opened on May 12, 2025
Issue body actions

Bug report

Bug description:

typing._UnionGenericAlias) became unshable somewhere between 3.13 and 3.14.0b1 (most likely in gh-105511)

import typing
hash(typing._UnionGenericAlias)
Traceback (most recent call last):
  File "<python-input-0>", line 2, in <module>
    hash(typing._UnionGenericAlias)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: '_UnionGenericAliasMeta'

This was hit in a doctest from astropy: xref astropy/astropy#18126
To be clear, the test in question doesn't necessarily correspond to a real-life application; we're testing that our itersubclasses utility function works in a very broad case where we try to retrieve all defined subclasses of object, and do a bit of internal book-keeping using a set of already-visited classes. This used to work in Python 3.13 (and seems to have worked with no interruption for 10+ years), so it still seemed worth a shot to see if that would be considered a bug here. Otherwise, it should be possible to fix the function on our side to either special case this exact class, ignore any unhashable class, or avoid reequiring hashability altogether.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

  • gh-133925: Make typing._UnionGenericAlias hashable #133929
  • [3.14] gh-133925: Make typing._UnionGenericAlias hashable (GH-133929) #133936

Activity

  1. neutrinoceros
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 12, 2025
  2. hugovk
    added
    topic-typing
    on May 12, 2025
  3. hugovk commented on May 12, 2025

    @hugovk
    hugovk
    on May 12, 2025
    Member
    More actions

    (most likely in gh-105511)

    Git bisect agrees, cc @JelleZijlstra.

    Reacted by Clément Robert
  4. JelleZijlstra
    added a commit that references this issue on May 12, 2025

    pythongh-133925: Make typing._UnionGenericAlias hashable

    a36291d
  5. JelleZijlstra commented on May 12, 2025

    @JelleZijlstra
    JelleZijlstra
    on May 12, 2025
    Member
    More actions

    It's because I added __eq__ but not __hash__ to the metaclass. Fix in #133929.

    Reacted by Hugo van Kemenade
  6. JelleZijlstra
    added a commit that references this issue on May 12, 2025

    gh-133925: Make typing._UnionGenericAlias hashable (#133929)

    8d478c7
  7. miss-islington
    added a commit that references this issue on May 12, 2025

    pythongh-133925: Make typing._UnionGenericAlias hashable (pythonGH-13…

    3efd377
  8. JelleZijlstra
    added a commit that references this issue on May 12, 2025

    [3.14] gh-133925: Make typing._UnionGenericAlias hashable (GH-133929) (…

    89c801b
  9. neutrinoceros commented on May 12, 2025

    @neutrinoceros
    neutrinoceros
    on May 12, 2025
    ContributorAuthor
    More actions

    Is there a reason to keep this open after the fox was merged ?

  10. AlexWaygood commented on May 12, 2025

    @AlexWaygood
    AlexWaygood
    on May 12, 2025
    Member
    More actions

    no, this is done now that the 🦊 is merged

    Reacted by Clément Robert and Raphael Gaschignard
  11. AlexWaygood
    closed this as completedon May 12, 2025
  12. neutrinoceros commented on May 12, 2025

    @neutrinoceros
    neutrinoceros
    on May 12, 2025
    ContributorAuthor
    More actions

    Thanks, all !

    Reacted by Alex Waygood
  13. SylvainDe
    added a commit that references this issue on May 26, 2025

    Allow coverage issues

    4870869
  14. Pranjal095
    added a commit that references this issue on Jul 12, 2025

    pythongh-133925: Make typing._UnionGenericAlias hashable (python#133929)

    8e42f57
  15. taegyunkim
    added a commit that references this issue on Aug 4, 2025

    pythongh-133925: Make typing._UnionGenericAlias hashable (python#133929)

    eba24a1
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

    topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.