From 091478e76c45627426e9423a4e4305a27069e445 Mon Sep 17 00:00:00 2001 From: da-woods Date: Tue, 2 Jun 2026 12:35:30 +0100 Subject: [PATCH] gh-58370 Document and test frozendict class matching behaviour Frozendict has `_Py_TPFLAGS_MATCH_SELF` set so works correctly with the single-arg class matching. However it isn't documented in the list of classes this works with and it isn't tested. The test is some way below the other similar tests but anything else would need a large renumbering --- Doc/reference/compound_stmts.rst | 1 + Lib/test/test_patma.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 63baefd33e88c50..71bfb608dda7283 100644 --- a/Doc/reference/compound_stmts.rst +++ b/Doc/reference/compound_stmts.rst @@ -1172,6 +1172,7 @@ subject value: * :class:`bytes` * :class:`dict` * :class:`float` + * :class:`frozendict` * :class:`frozenset` * :class:`int` * :class:`list` diff --git a/Lib/test/test_patma.py b/Lib/test/test_patma.py index 29cce4ee6d271ff..52b36611e40a443 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2852,6 +2852,15 @@ def test_patma_266(self): self.assertEqual(x, 0) self.assertEqual(y, 1) + def test_patma_267(self): + x = frozendict() + match x: + case frozendict(z): + y = 0 + self.assertEqual(x, frozendict()) + self.assertEqual(y, 0) + self.assertIs(z, x) + def test_patma_runtime_checkable_protocol(self): # Runtime-checkable protocol from typing import Protocol, runtime_checkable