Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f06d53a
Objects/dictobject.c
iritkatriel Feb 23, 2023
d5072bd
Objects/frameobject.c
iritkatriel Feb 23, 2023
c40fc27
Objects/genobject.c
iritkatriel Feb 23, 2023
13cb48c
Objects/object.c
iritkatriel Feb 23, 2023
fde54d4
Objects/odictobject.c
iritkatriel Feb 23, 2023
8fd66a8
Objects/typeobject.c
iritkatriel Feb 23, 2023
d83af14
Objects/weakrefobject.c
iritkatriel Feb 23, 2023
0298a04
Objects/exceptions.c
iritkatriel Feb 23, 2023
09f2ab6
put back the Py_DECREF(exc)
iritkatriel Feb 24, 2023
0fef293
Merge branch 'main' into fetch-restore-objects
iritkatriel Feb 24, 2023
9b5b62a
Merge branch 'main' into fetch-restore-objects
iritkatriel Feb 25, 2023
6378d56
Merge branch 'main' into fetch-restore-objects
iritkatriel Feb 26, 2023
e11d73e
Merge branch 'main' into fetch-restore-objects
iritkatriel Feb 27, 2023
eb45902
Merge branch 'main' into fetch-restore-objects
iritkatriel Feb 27, 2023
526e387
Merge branch 'main' into fetch-restore-objects
iritkatriel Feb 28, 2023
a579bc4
Merge branch 'main' into fetch-restore-objects
iritkatriel Feb 28, 2023
e5bf89d
Merge branch 'main' into fetch-restore-objects
iritkatriel Feb 28, 2023
0863f35
Merge branch 'main' into fetch-restore-objects
iritkatriel Mar 1, 2023
3f8b452
Merge branch 'main' into fetch-restore-objects
iritkatriel Mar 2, 2023
7a436c9
Merge branch 'main' into fetch-restore-objects
iritkatriel Mar 2, 2023
9b68505
remove redundant null check and obsolete comments (Mark's review comm…
iritkatriel Mar 3, 2023
c23baa2
Merge branch 'main' into fetch-restore-objects
iritkatriel Mar 3, 2023
44bead6
Merge branch 'main' into fetch-restore-objects
iritkatriel Mar 6, 2023
d592920
Merge branch 'main' into fetch-restore-objects
iritkatriel Mar 6, 2023
e136989
Merge branch 'main' into fetch-restore-objects
iritkatriel Mar 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Objects/object.c
  • Loading branch information
iritkatriel committed Feb 23, 2023
commit 13cb48c8410ba43390f8a3e32005e8ec632cfb0d
26 changes: 11 additions & 15 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,12 @@ _PyObject_Dump(PyObject* op)
fflush(stderr);

PyGILState_STATE gil = PyGILState_Ensure();
PyObject *error_type, *error_value, *error_traceback;
PyErr_Fetch(&error_type, &error_value, &error_traceback);
PyObject *exc = PyErr_GetRaisedException();

(void)PyObject_Print(op, stderr, 0);
fflush(stderr);

PyErr_Restore(error_type, error_value, error_traceback);
PyErr_SetRaisedException(exc);
PyGILState_Release(gil);

fprintf(stderr, "\n");
Expand Down Expand Up @@ -860,25 +859,23 @@ set_attribute_error_context(PyObject* v, PyObject* name)
return 0;
}
// Intercept AttributeError exceptions and augment them to offer suggestions later.
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
PyErr_NormalizeException(&type, &value, &traceback);
// Check if the normalized exception is indeed an AttributeError
if (!PyErr_GivenExceptionMatches(value, PyExc_AttributeError)) {
PyObject *exc = PyErr_GetRaisedException();
// Check if the exception is indeed an AttributeError
Comment thread
iritkatriel marked this conversation as resolved.
Outdated
if (!PyErr_GivenExceptionMatches(exc, PyExc_AttributeError)) {
goto restore;
}
PyAttributeErrorObject* the_exc = (PyAttributeErrorObject*) value;
PyAttributeErrorObject* the_exc = (PyAttributeErrorObject*) exc;
// Check if this exception was already augmented
if (the_exc->name || the_exc->obj) {
goto restore;
}
// Augment the exception with the name and object
if (PyObject_SetAttr(value, &_Py_ID(name), name) ||
PyObject_SetAttr(value, &_Py_ID(obj), v)) {
if (PyObject_SetAttr(exc, &_Py_ID(name), name) ||
PyObject_SetAttr(exc, &_Py_ID(obj), v)) {
return 1;
}
restore:
PyErr_Restore(type, value, traceback);
PyErr_SetRaisedException(exc);
return 0;
}

Expand Down Expand Up @@ -2190,9 +2187,8 @@ Py_ReprLeave(PyObject *obj)
PyObject *dict;
PyObject *list;
Py_ssize_t i;
PyObject *error_type, *error_value, *error_traceback;

PyErr_Fetch(&error_type, &error_value, &error_traceback);
PyObject *exc = PyErr_GetRaisedException();

dict = PyThreadState_GetDict();
if (dict == NULL)
Expand All @@ -2213,7 +2209,7 @@ Py_ReprLeave(PyObject *obj)

finally:
/* ignore exceptions because there is no way to report them. */
PyErr_Restore(error_type, error_value, error_traceback);
PyErr_SetRaisedException(exc);
}

/* Trashcan support. */
Expand Down