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

gh-141510: Check argument in PyDict_Contains() by vstinner · Pull Request #145083 · python/cpython · GitHub

/ cpython Public

gh-141510: Check argument in PyDict_Contains() - #145083

Merged
vstinner merged 2 commits into
python:mainfrom
vstinner:frozendict_dict_contains
Feb 21, 2026
Merged

gh-141510: Check argument in PyDict_Contains()#145083
vstinner merged 2 commits into
python:mainfrom
vstinner:frozendict_dict_contains

Conversation

vstinner commented Feb 21, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

PyDict_Contains() and PyDict_ContainsString() now fail with SystemError if the first argument is not a dict, frozendict, dict subclass or frozendict subclass.

PyDict_Contains() and PyDict_ContainsString() now fail with
SystemError if the first argument is not a dict, frozendict, dict
subclass or frozendict subclass.
Comment thread Objects/dictobject.c
Comment on lines +5004 to +5007
if (!PyAnyDict_Check(op)) {
PyErr_BadInternalCall();
return -1;
}

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

Would you mind adding a versionchanged for this in the docs? This looks good otherwise.

Copy link
Copy Markdown
Member Author

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

We do not document SystemError errors in the documentation. It's not really part of the API, but provided to be kind with developers.

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

I'm not sure that's necessarily a good thing. It's helpful for extension authors to know whether they need to validate their input.

Copy link
Copy Markdown
Member Author

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

They always need to validate their input. You're not supposed to hit SystemError in regular code.

vstinner merged commit c9380ae into python:main Feb 21, 2026
45 checks passed
vstinner deleted the frozendict_dict_contains branch February 21, 2026 17:36
brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
PyDict_Contains() and PyDict_ContainsString() now fail with
SystemError if the first argument is not a dict, frozendict, dict
subclass or frozendict subclass.
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
PyDict_Contains() and PyDict_ContainsString() now fail with
SystemError if the first argument is not a dict, frozendict, dict
subclass or frozendict subclass.
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