summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 2986622..1ec2144 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -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__), &notes);
+ if (res <= 0) {
+ return res;
}
if (!PySequence_Check(notes) || PyUnicode_Check(notes) || PyBytes_Check(notes)) {
- int res = 0;
+ res = 0;
if (write_indented_margin(ctx, f) < 0) {
res = -1;
}