-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-99139: Improve NameError error suggestion for instances #99140
Conversation
pablogsal
commented
Nov 5, 2022
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- Issue: Improve NameError error suggestion for instances #99139
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great :)
Co-authored-by: Ammar Askar <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really helpful, thanks a lot @pablogsal!
🤖 New build scheduled with the buildbot fleet by @pablogsal for commit b1546e5 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Co-authored-by: Ammar Askar <[email protected]>
Co-authored-by: Batuhan Taskaya <[email protected]>
Co-authored-by: Batuhan Taskaya <[email protected]>
🤖 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 <[email protected]>
if (!locals) { | ||
goto error; | ||
} | ||
PyObject* self = PyDict_GetItem(locals, &_Py_ID(self)); /* borrowed */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use PyDict_GetItem
. It is broken by design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should we use instead for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use PyObject_HasAttr
. It is broken by design.