gh-99139: Improve NameError error suggestion for instances#99140
gh-99139: Improve NameError error suggestion for instances#99140pablogsal merged 7 commits intopython:mainfrom
Conversation
Co-authored-by: Ammar Askar <ammar_askar@hotmail.com>
isidentical
left a comment
There was a problem hiding this comment.
Looks really helpful, thanks a lot @pablogsal!
Co-authored-by: Ammar Askar <ammar_askar@hotmail.com>
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
|
🤖 New build scheduled with the buildbot fleet by @pablogsal for commit 4925719 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
| if (!locals) { | ||
| goto error; | ||
| } | ||
| PyObject* self = PyDict_GetItem(locals, &_Py_ID(self)); /* borrowed */ |
There was a problem hiding this comment.
Do not use PyDict_GetItem. It is broken by design.
There was a problem hiding this comment.
What should we use instead for both?
There was a problem hiding this comment.
PyDict_GetItemWithError and PyObject_GetAttr if limited by public API. It is suggested in the documentation. But _PyObject_LookupAttr is more convenient in the latter case.
| goto error; | ||
| } | ||
|
|
||
| if (PyObject_HasAttr(self, name)) { |
There was a problem hiding this comment.
Do not use PyObject_HasAttr. It is broken by design.

Uh oh!
There was an error while loading. Please reload this page.