Uh oh!
There was an error while loading. Please reload this page.
[mypyc] Replace _CPyObject_HasAttr with PyObject_HasAttrWithError - #20535
Conversation
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)) { |
There was a problem hiding this comment.
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 :/
There was a problem hiding this comment.
Wouldn't this return
-1on 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
There was a problem hiding this comment.
I guess if you want minimal PRs this can be fixed in a followup then...
There was a problem hiding this comment.
Just pushed a new commit to explicitly check for > 0. That should resolve that issue as well.
Uh oh!
There was an error while loading. Please reload this page.
https://docs.python.org/3/c-api/object.html#c.PyObject_HasAttrWithError