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

[mypyc] Replace _CPyObject_HasAttr with PyObject_HasAttrWithError by cdce8p · Pull Request #20535 · python/mypy · GitHub

Repository navigation

[mypyc] Replace _CPyObject_HasAttr with PyObject_HasAttrWithError - #20535

Merged
JukkaL merged 2 commits into
python:masterfrom
cdce8p:mypyc-hasattr
Jan 8, 2026
Merged

JukkaL merged 2 commits into
python:masterfrom
cdce8p:mypyc-hasattr

Conversation

cdce8p commented Jan 6, 2026

Copy link
Copy Markdown
Collaborator

cdce8p added the topic-mypyc mypyc bugs label Jan 6, 2026

cdce8p commented Jan 6, 2026

Copy link
Copy Markdown
Collaborator Author

Followup to #20460 (comment)

Comment thread mypyc/lib-rt/dict_ops.c Outdated
if (PyDict_CheckExact(dict)) {
// Argh this sucks
if (PyDict_Check(stuff) || _CPyObject_HasAttr(stuff, mypyc_interned_str.keys)) {
if (PyDict_Check(stuff)|| PyObject_HasAttrWithError(stuff, mypyc_interned_str.keys)) {

Copy link
Copy Markdown
Collaborator

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

Wouldn't this return -1 on failure which would be bad and trigger the if? (when would that failure be...)

I'm not very familiar with C so maybe I'm wrong :/

Copy link
Copy Markdown
Collaborator 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

Wouldn't this return -1 on failure

Yes, but that's already returned from _CPyObject_HasAttr on failure as well.
https://docs.python.org/3/c-api/object.html#c.PyObject_GetOptionalAttr

Copy link
Copy Markdown
Collaborator

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 guess if you want minimal PRs this can be fixed in a followup then...

Copy link
Copy Markdown
Collaborator 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

Just pushed a new commit to explicitly check for > 0. That should resolve that issue as well.

JukkaL merged commit 9dc9fc3 into python:master Jan 8, 2026
16 checks passed
cdce8p deleted the mypyc-hasattr branch January 8, 2026 16:42
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

Labels

topic-mypyc mypyc bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL