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 — Many pure python tools that have a special cases for dict should accept frozendict as well. · Issue #145056 · python/cpython

Many pure python tools that have a special cases for dict should accept frozendict as well. #145056

New issue
Copy link
New issue
Copy link
Open
1 / 11 of 1 issue completed
Open
Many pure python tools that have a special cases for dict should accept frozendict as well.#145056
1 / 11 of 1 issue completed
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@rhettinger
rhettinger
opened on Feb 20, 2026
Issue body actions

I'll fix the ones in collections. Some other priorities are pprint and ElementTree

Here's a rg dict | rg isinstance scan of the Lib directory:

unittest/mock.py:        if isinstance(self.in_dict, str):
trace.py:                             if isinstance(d, dict)]
rlcompleter.py:        if namespace and not isinstance(namespace, dict):
rlcompleter.py:                        isinstance(thisobject.__dict__.get(word),
tomllib/_parser.py:            if not isinstance(cont, dict):
tomllib/_parser.py:    if isinstance(value, (dict, list)):
tomllib/_parser.py:        if isinstance(value, (dict, list)):
tomllib/_parser.py:        if isinstance(float_value, (dict, list)):
multiprocessing/managers.py:                if not isinstance(method_to_typeid, dict):
functools.py:           (kwds is not None and not isinstance(kwds, dict)) or
functools.py:           (namespace is not None and not isinstance(namespace, dict))):
pprint.py:        if isinstance(object, self._dict_items_view):
turtle.py:        if isinstance(pen, dict):
optparse.py:                not isinstance(self.callback_kwargs, dict)):
optparse.py:        elif isinstance(other, dict):
linecache.py:    if module_globals is not None and not isinstance(module_globals, dict):
xml/etree/ElementTree.py:        if not isinstance(attrib, dict):
_pyrepl/input.py:        if isinstance(d, dict):
tkinter/__init__.py:    if isinstance(cnfs, dict):
tkinter/__init__.py:        if isinstance(cnf, (dict, tuple)):
_pyrepl/base_eventqueue.py:            if isinstance(k, dict):
test/_test_multiprocessing.py:    def test_dict_isinstance(self):
_pyrepl/readline.py:    if not isinstance(namespace, dict):
logging/config.py:        if not isinstance(value, ConvertingDict) and isinstance(value, dict):
logging/config.py:                    elif isinstance(qspec, dict):
logging/config.py:                        elif isinstance(lspec, dict):
logging/config.py:                            assert isinstance(d, dict)
test/test_pyrepl/test_terminfo.py:                        isinstance(ncurses_data[key], dict)
test/test_pyrepl/test_terminfo.py:                            isinstance(ncurses_data[key], dict)
test/test_launcher.py:        if isinstance(value, dict):
test/test_launcher.py:            tags = [t for t in company_data if isinstance(company_data[t], dict)]
test/test_launcher.py:            tags = [t for t in company_data if isinstance(company_data[t], dict)]
test/test_isinstance.py:        self.assertFalse(issubclass(dict, float|str))
test/test_marshal.py:    elif isinstance(obj, dict):
test/test_format.py:    if isinstance(args, dict):
test/test_build_details.py:                        self.assertFalse(isinstance(sys.implementation.version, dict))
_pydecimal.py:        elif not isinstance(traps, dict):
_pydecimal.py:        elif not isinstance(flags, dict):
_pydecimal.py:        if not isinstance(d, dict):
collections/__init__.py:        if not isinstance(other, dict):
collections/__init__.py:        if not isinstance(other, dict):
collections/__init__.py:        if isinstance(other, dict):
collections/__init__.py:        if isinstance(other, dict):
test/test_module/__init__.py:        self.assertTrue(isinstance(foo.__dict__, dict))
profiling/sampling/heatmap_collector.py:            if isinstance(data, dict):
test/test_code.py:                if isinstance(globalvars, dict):
test/test_urllib2_localnet.py:        assert isinstance(users, dict)
annotationlib.py:            or isinstance(self.__cell__, dict)
annotationlib.py:        if isinstance(self.__cell__, dict):
annotationlib.py:                if isinstance(self.__cell__, dict) and isinstance(other.__cell__, dict)
annotationlib.py:                if isinstance(self.__cell__, dict) else id(self.__cell__),
annotationlib.py:        if not isinstance(ann, dict):
annotationlib.py:    if not isinstance(ann, dict):
test/test_io/test_general.py:                if isinstance(v, dict):
test/test_compiler_assemble.py:            elif isinstance(value, dict):
json/encoder.py:                    elif isinstance(value, dict):
json/encoder.py:                    elif isinstance(value, dict):
json/encoder.py:        elif isinstance(o, dict):
plistlib.py:            if not isinstance(self.stack[-1], dict):
plistlib.py:        if self.current_key or not isinstance(self.stack[-1], dict):
plistlib.py:        elif isinstance(value, dict):
plistlib.py:        if isinstance(value, dict):
plistlib.py:        elif isinstance(value, dict):
test/test_tomllib/burntsushi.py:    elif isinstance(obj, dict):
test/test_tomllib/burntsushi.py:    if isinstance(obj, dict):
inspect.py:        if isinstance(dict_obj, (staticmethod, types.BuiltinMethodType)):
inspect.py:        elif isinstance(dict_obj, (classmethod, types.ClassMethodDescriptorType)):
inspect.py:        elif isinstance(dict_obj, property):
inspect.py:            if isinstance(slots, dict) and name in slots:
inspect.py:            (kwdefaults is None or isinstance(kwdefaults, dict)))
xmlrpc/client.py:        if isinstance(item, dict):
test/test_importlib/resources/zip.py:        if isinstance(contents, dict):
importlib/_bootstrap_external.py:    if not isinstance(module_globals, dict):
test/test_descrtut.py:    >>> isinstance([], dict)
enum.py:    if isinstance(obj, dict):
test/test_import/test_lazy_imports.py:            assert isinstance(sys.lazy_modules, dict), "sys.lazy_modules is not a dict"
test/test_type_annotations.py:                if not isinstance(self.my_annotations, dict):
test/test_type_annotations.py:                if not isinstance(value, dict):
dataclasses.py:    elif isinstance(obj, dict):
test/string_tests.py:        elif isinstance(obj, dict):
test/test_pyclbr.py:                if (not isinstance(classdict[name], ClassMethodType) or
compression/zstd/_zstdfile.py:        if options is not None and not isinstance(options, dict):
compression/zstd/__init__.py:    if not isinstance(dict_size, int):
compression/zstd/__init__.py:    if not isinstance(zstd_dict, ZstdDict):
compression/zstd/__init__.py:    if not isinstance(dict_size, int):

Linked PRs

  • gh-145056: Let dict specific tests accept frozendict as well #145060
  • gh-145056: Add support for frozendict in dataclass asdict and astuple #145125
  • gh-145056: Accept frozendict in xml.etree #145508
  • gh-145056: Fix merging of OrderedDict and UserDict with frozendict #146295
  • gh-145056: Add support for merging collections.UserDict and frozendict #146465
  • gh-145056: Fix merging of collections.OrderedDict and frozendict #146466
  • gh-145056: Support frozendict in reprlib #159468

Activity

Next
  1. eendebakpt commented on Feb 20, 2026

    @eendebakpt
    eendebakpt
    on Feb 20, 2026
    Contributor
    More actions

    I looked into the dataclasses cases. A frozendict is currently handled fine, but not exactly as a dict. However, the same is true for classes that behave like a mapping so maybe this is ok. A minimal example:

    from dataclasses import dataclass, asdict, astuple
    
    @dataclass
    class A:
        d: dict
        f: frozendict
    
    
    lst = []
    d = {"a": lst, "b": lst}
    a = A(d, frozendict(d))
    
    at = astuple(a)  # runs fine
    print(at)  # looks good
    print(at[0]["a"] is at[0]["b"])  # False
    print(
        at[1]["a"] is at[1]["b"]
    )  # frozendict is handled by deepcopy, so this returns True
    
    ad = asdict(a)  # runs fine
    print(ad)  # looks good
    print(at["d"]["a"] is at["d"]["b"])  # False
    print(at["f"]["a"] is at["f"]["b"])  # True

    Note: the search could be extended with a pattern for issubclass(obj_type, dict) (found in dataclasses.py)

  2. picnixz
    added
    type-featureA feature request or enhancementA feature request or enhancement
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Feb 20, 2026
  3. rhettinger
    added a commit that references this issue on Feb 21, 2026

    pythongh-145056: Let dict specific tests accept frozendict as well

    f27f128
  4. devdanzin commented on Feb 21, 2026

    @devdanzin
    devdanzin
    on Feb 21, 2026
    Member
    More actions

    I'll try to handle pprint.

  5. hugovk commented on Feb 21, 2026

    @hugovk
    hugovk
    on Feb 21, 2026
    Member
    More actions

    I'll try to handle pprint.

    See also #144908 for some pprint changes and the umbrella issue #141510.

  6. devdanzin
    added a sub-issue on Feb 21, 2026
    • Teach pprint about frozendict #145070
  7. devdanzin commented on Feb 21, 2026

    @devdanzin
    devdanzin
    on Feb 21, 2026
    Member
    More actions

    Oh, that makes my issue a duplicate. Thanks for the heads up.

    Edit: leaving it open as it's more focused than the umbrella issue, feel free to close if you disagree.

  8. abdoulrasheed commented on Mar 1, 2026

    @abdoulrasheed
    abdoulrasheed
    on Mar 1, 2026
    Contributor
    More actions

    Related incomplete migration: #144904 changed _EMPTY_METADATA to frozendict() but left the non-empty case as types.MappingProxyType(metadata) at dataclasses:306.

    This creates a type inconsistency:

    from dataclasses import dataclass, field, fields
    
    @dataclass
    class C:
        a: int
        b: int = field(metadata={'k': 'v'})
    
    f_a, f_b = fields(C)
    type(f_a.metadata)  # frozendict
    type(f_b.metadata)  # mappingproxy
    hash(f_a.metadata)  # works
    hash(f_b.metadata)  # TypeError: unhashable type: 'dict'

    This could potentially be folded into #145125 since it's already touching dataclasses.py.

  9. vstinner
    added a commit that references this issue on Mar 4, 2026

    pythongh-145056: Accept frozendict in xml.etree

    5d0d438
  10. vstinner commented on Mar 4, 2026

    @vstinner
    vstinner
    on Mar 4, 2026
    Member
    More actions

    I'll fix the ones in collections. Some other priorities are pprint and ElementTree

    I created #145508 to accept frozendict in xml.etree.

  11. vstinner
    added a commit that references this issue on Mar 5, 2026

    gh-145056: Accept frozendict in xml.etree (#145508)

    7bdfce0
  12. vstinner
    added a parent issue on Mar 6, 2026
    • PEP 814: Add built-in frozendict type #141510
  13. serhiy-storchaka
    added 2 commits that reference this issue on Mar 26, 2026

    pythongh-145056: Add support for merging collections.UserDict and fro…

    fb52639

    pythongh-145056: Fix merging of collections.OrderedDict and frozendict

    0c8cbb0
  14. 2 remaining items

  15. serhiy-storchaka
    added 3 commits that reference this issue on Mar 26, 2026

    pythongh-145056: Fix merging of collections.OrderedDict and frozendict

    01a5ae5

    gh-145056: Fix merging of collections.OrderedDict and frozendict (GH-…

    7278904

    gh-145056: Add support for merging collections.UserDict and frozendict (

    ec2bc12
  16. maurycy
    added a commit that references this issue on Mar 31, 2026

    Merge branch 'main' into tachyon-ndjson-kolektor

    9836ffa
  17. clin1234
    added 2 commits that reference this issue on Apr 16, 2026

    pythongh-145056: Fix merging of collections.OrderedDict and frozendict (

    129f815

    pythongh-145056: Add support for merging collections.UserDict and fro…

    149588f
  18. JelleZijlstra
    added a commit that references this issue on Apr 23, 2026

    gh-145056: Add support for frozendict in dataclass asdict and astuple (…

    8e43f3d
  19. ljfp
    added 4 commits that reference this issue on Apr 25, 2026

    pythongh-145056: Accept frozendict in xml.etree (python#145508)

    d6294fc

    pythongh-145056: Fix merging of collections.OrderedDict and frozendict (

    5613cbd

    pythongh-145056: Add support for merging collections.UserDict and fro…

    74a1606

    pythongh-145056: Add support for frozendict in dataclass asdict and a…

    0046d00
  20. skippdot
    added a commit that references this issue on Oct 15, 2026

    feat(pythongh-145056): Support frozendict in reprlib

    8d84daa
  21. kevinprimeraquecreo-stack
    added this to Project_VKon Oct 18, 2026
  22. github-project-automation
    moved this to Todo in Project_VKon Oct 18, 2026
  23. kevinprimeraquecreo-stack
    added this to Project_VKon Oct 18, 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

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

    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.