Skip to content

Commit fd53ae1

Browse files
authored
gh-141510 Document and test frozendict class matching behaviour (#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.
1 parent 8b270b7 commit fd53ae1

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Doc/reference/compound_stmts.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,7 @@ subject value:
11721172
* :class:`bytes`
11731173
* :class:`dict`
11741174
* :class:`float`
1175+
* :class:`frozendict`
11751176
* :class:`frozenset`
11761177
* :class:`int`
11771178
* :class:`list`

Lib/test/test_patma.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,15 @@ def test_patma_266(self):
28522852
self.assertEqual(x, 0)
28532853
self.assertEqual(y, 1)
28542854

2855+
def test_patma_frozendict_class_self(self):
2856+
x = frozendict()
2857+
match x:
2858+
case frozendict(z):
2859+
y = 0
2860+
self.assertEqual(x, frozendict())
2861+
self.assertEqual(y, 0)
2862+
self.assertIs(z, x)
2863+
28552864
def test_patma_runtime_checkable_protocol(self):
28562865
# Runtime-checkable protocol
28572866
from typing import Protocol, runtime_checkable

0 commit comments

Comments
 (0)