Skip to content

gh-141510 Document and test frozendict class matching behaviour#150799

Merged
vstinner merged 2 commits into
python:mainfrom
da-woods:frozendict-self-match
Jun 18, 2026
Merged

gh-141510 Document and test frozendict class matching behaviour#150799
vstinner merged 2 commits into
python:mainfrom
da-woods:frozendict-self-match

Conversation

@da-woods

@da-woods da-woods commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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

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
@da-woods

da-woods commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

I'm assuming this is fine to bundle onto the original frozendict issue, but can change that if needed

(...Although I originally linked it to a previous reject proposal by mistake...)

@read-the-docs-community

read-the-docs-community Bot commented Jun 2, 2026

Copy link
Copy Markdown

@da-woods da-woods changed the title gh-58370 Document and test frozendict class matching behaviour gh-141510 Document and test frozendict class matching behaviour Jun 4, 2026
Comment thread Lib/test/test_patma.py Outdated
self.assertEqual(x, 0)
self.assertEqual(y, 1)

def test_patma_267(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the rationale for using an identifier to name the test method. Can you rename it to test_patma_frozendict()?

@vstinner

Copy link
Copy Markdown
Member

Oh, I didn't notice that I copied _Py_TPFLAGS_MATCH_SELF flag when I implemented frozendict. Thanks for updating the tests and the doc!

@da-woods

Copy link
Copy Markdown
Contributor Author

Oh, I didn't notice that I copied _Py_TPFLAGS_MATCH_SELF flag when I implemented frozendict

I guess it isn't too late to remove the flag of you don't want it. But I think the flag makes sense.

I've updated the function name to be more descriptive

@vstinner vstinner merged commit fd53ae1 into python:main Jun 18, 2026
51 checks passed
@vstinner

Copy link
Copy Markdown
Member

Thanks, I merged your change.

@da-woods da-woods deleted the frozendict-self-match branch June 18, 2026 13:46
@vstinner vstinner added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 19, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @da-woods for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jun 19, 2026

Copy link
Copy Markdown

GH-151701 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 19, 2026
vstinner pushed a commit that referenced this pull request Jun 19, 2026
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 fd53ae1)

Co-authored-by: da-woods <dw-git@d-woods.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants