From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 19 Jun 2026 08:45:02 +0000 (+0200) Subject: [3.15] gh-141510 Document and test frozendict class matching behaviour (GH-150799... X-Git-Tag: v3.15.0b3~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e368380f899c0b83b3b4b383371481021d9aabe;p=thirdparty%2FPython%2Fcpython.git [3.15] gh-141510 Document and test frozendict class matching behaviour (GH-150799) (#151701) gh-141510 Document and test frozendict class matching behaviour (GH-150799) 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. (cherry picked from commit fd53ae113911e5a7d83c04b08623df824f9d5d70) Co-authored-by: da-woods --- diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst index 63baefd33e88..71bfb608dda7 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 29cce4ee6d27..e3aaea84ea7c 100644 --- a/Lib/test/test_patma.py +++ b/Lib/test/test_patma.py @@ -2852,6 +2852,15 @@ class TestPatma(unittest.TestCase): self.assertEqual(x, 0) self.assertEqual(y, 1) + def test_patma_frozendict_class_self(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