FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-141510: Raise TypeError in PyDict_SetItem() on frozendict by vstinner · Pull Request #145564 · python/cpython · GitHub

/ cpython Public

gh-141510: Raise TypeError in PyDict_SetItem() on frozendict - #145564

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:pydict_setitem
Mar 11, 2026
Merged

gh-141510: Raise TypeError in PyDict_SetItem() on frozendict#145564
vstinner merged 1 commit into
python:mainfrom
vstinner:pydict_setitem

Conversation

vstinner commented Mar 5, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

If the following functions get an unexpected frozendict, raise a TypeError with an useful error message:

  • PyDict_DelItem()
  • PyDict_DelItemString()
  • PyDict_Merge()
  • PyDict_MergeFromSeq2()
  • PyDict_Pop()
  • PyDict_PopString()
  • PyDict_SetDefault()
  • PyDict_SetDefaultRef()
  • PyDict_SetItem()
  • PyDict_SetItemString()
  • _PyDict_SetItem_KnownHash()
  • PyDict_Update()

If the following functions get an unexpected frozendict, raise a
TypeError with an useful error message:

* PyDict_DelItem()
* PyDict_DelItemString()
* PyDict_Merge()
* PyDict_MergeFromSeq2()
* PyDict_Pop()
* PyDict_PopString()
* PyDict_SetDefault()
* PyDict_SetDefaultRef()
* PyDict_SetItem()
* PyDict_SetItemString()
* _PyDict_SetItem_KnownHash()
* PyDict_Update()

Co-Authored-by: mohsinm-dev <mohsin.mdev@gmail.com>

vstinner commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

This change raises a nice TypeError exception with an useful error message when a frozendict is passed to a PyDict function which tries to modify it (ex: PyDict_SetItem).

The initial version of the code is based on PR gh-145123.

corona10 left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Generally looks good to me, but let me take a look til this weekend.

corona10 self-assigned this Mar 9, 2026

corona10 left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lgtm

vstinner merged commit 713be70 into python:main Mar 11, 2026
56 checks passed
vstinner deleted the pydict_setitem branch March 11, 2026 16:05

Copy link
Copy Markdown
Member Author

Merged. Thanks for the review @corona10.

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

If the following functions get an unexpected frozendict,
raise TypeError instead of SystemError:

* PyDict_DelItem()
* PyDict_DelItemString()
* PyDict_Merge()
* PyDict_MergeFromSeq2()
* PyDict_Pop()
* PyDict_PopString()
* PyDict_SetDefault()
* PyDict_SetDefaultRef()
* PyDict_SetItem()
* PyDict_SetItemString()
* _PyDict_SetItem_KnownHash()
* PyDict_Update()

Co-authored-by: mohsinm-dev <mohsin.mdev@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL