Skip to content

defaultdict | frozendict returns dict, not defaultdict #149534

Closed

Description

@JelleZijlstra

Bug report

Bug description:

Compare:

>>> type(defaultdict(int) | frozendict())
<class 'dict'>
>>> type(OrderedDict() | frozendict())
<class 'collections.OrderedDict'>
>>> type(defaultdict(int) | dict())
<class 'collections.defaultdict'>

This should be fixable by making defaultdict's nb_or use PyAnyDict_Check instead of PyDict_Check.

CPython versions tested on:

3.15

Operating systems tested on:

No response

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    3.15bugs and security fixes
    on May 8, 2026
  2. changed the title [-]defaultdict | frozendict returns dict, not defaultdict[/-] [+]`defaultdict | frozendict` returns `dict`, not `defaultdict`[/+] on May 9, 2026
  3. added 2 commits that reference this issue on Jun 1, 2026
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

    3.15bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions