-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr #106034
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1134,15 +1134,13 @@ print_exception_notes(struct exception_print_context *ctx, PyObject *value) | |
return 0; | ||
} | ||
|
||
if (!PyObject_HasAttr(value, &_Py_ID(__notes__))) { | ||
return 0; | ||
} | ||
PyObject *notes = PyObject_GetAttr(value, &_Py_ID(__notes__)); | ||
if (notes == NULL) { | ||
return -1; | ||
PyObject *notes; | ||
int res = _PyObject_LookupAttr(value, &_Py_ID(__notes__), ¬es); | ||
if (res <= 0) { | ||
return res; | ||
} | ||
if (!PySequence_Check(notes) || PyUnicode_Check(notes) || PyBytes_Check(notes)) { | ||
int res = 0; | ||
res = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a reason not to have this local to the block? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will hide the same named variable in the outer block. It looks errorprone, even if it does not do wrong in this case. The compiler can complain, and I would not blame it on this. |
||
if (write_indented_margin(ctx, f) < 0) { | ||
res = -1; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.