Skip to content

Conversation

@cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Jan 6, 2026

@cdce8p cdce8p added the topic-mypyc mypyc bugs label Jan 6, 2026
@cdce8p
Copy link
Collaborator Author

cdce8p commented Jan 6, 2026

Followup to #20460 (comment)

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
Collaborator

Choose a reason for hiding this comment

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

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
Collaborator Author

Choose a reason for hiding this comment

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

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
Collaborator

Choose a reason for hiding this comment

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

I guess if you want minimal PRs this can be fixed in a followup then...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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

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.

2 participants