Skip to content

gh-141510: Don't accept frozendict in PyDict_Watch() - #145529

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:dict_watch
Mar 5, 2026
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:dict_watch

Conversation

@vstinner

@vstinner vstinner commented Mar 5, 2026 •

Copy link
Copy Markdown
Member

Don't accept frozendict in PyDict_Watch() and PyDict_Unwatch(). A frozendict cannot be modified, so it's not useful to watch for modifications.

Don't accept frozendict in PyDict_Watch() and PyDict_Unwatch(). A
frozendict cannot be modified, so it's not useful to watch for
modifications.
@vstinner

vstinner commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

I don't recall why I modified PyDict_Watch() and PyDict_Unwatch() to accept frozendict in my commit 696cdfc. Maybe I just replaced mechanically PyDict_Check() with PyAnyDict_Check().

A frozendict cannot be modified, so it's not useful to watch for modifications.

If later, it becomes useful, we can modify the functions again. But I prefer to start by not accepting them.

@vstinner

vstinner commented Mar 5, 2026

Copy link
Copy Markdown
Member Author
@vstinner
vstinner merged commit 0fe20fc into python:main Mar 5, 2026
52 checks passed
@vstinner
vstinner deleted the dict_watch branch March 5, 2026 11:31
@vstinner

vstinner commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

Merged. Thanks for the review @Fidget-Spinner.

ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
…5529)

Don't accept frozendict in PyDict_Watch() and PyDict_Unwatch().
A frozendict cannot be modified, so it's not useful to watch for
modifications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants