10000 gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr by serhiy-storchaka · Pull Request #106034 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
8000 Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review comments.
  • Loading branch information
serhiy-storchaka committed Jun 23, 2023
commit 4ae982e50d52dfe5a665ee9a0ed9d11ada0f3ffc
4 changes: 2 additions & 2 deletions Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ BaseException_add_note(PyObject *self, PyObject *note)
if (_PyObject_LookupAttr(self, &_Py_ID(__notes__), &notes) < 0) {
return NULL;
}
if (!notes) {
if (notes == NULL) {
notes = PyList_New(0);
if (notes == NULL) {
return NULL;
Expand All @@ -221,7 +221,7 @@ BaseException_add_note(PyObject *self, PyObject *note)
return NULL;
}
}
if (!PyList_Check(notes)) {
else if (!PyList_Check(notes)) {
Py_DECREF(notes);
PyErr_SetString(PyExc_TypeError, "Cannot add note: __notes__ is not a list");
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,10 +1153,10 @@ print_exception_notes(struct exception_print_context *ctx, PyObject *value)
res = PyFile_WriteObject(s, f, Py_PRINT_RAW);
Py_DECREF(s);
}
Py_DECREF(notes);
if (PyFile_WriteString("\n", f) < 0) {
res = -1;
}
Py_DECREF(notes);
return res;
}
Py_ssize_t num_notes = PySequence_Length(notes);
Expand Down
0