mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
PEP 415: Implement suppression of __context__ display with an exception attribute
This replaces the original PEP 409 implementation. See #14133.
This commit is contained in:
parent
d91dc62379
commit
d5a1c44455
12 changed files with 80 additions and 79 deletions
|
@ -1761,11 +1761,7 @@ print_exception_recursive(PyObject *f, PyObject *value, PyObject *seen)
|
|||
else if (PyExceptionInstance_Check(value)) {
|
||||
cause = PyException_GetCause(value);
|
||||
context = PyException_GetContext(value);
|
||||
if (cause && cause == Py_None) {
|
||||
/* print neither cause nor context */
|
||||
;
|
||||
}
|
||||
else if (cause) {
|
||||
if (cause) {
|
||||
res = PySet_Contains(seen, cause);
|
||||
if (res == -1)
|
||||
PyErr_Clear();
|
||||
|
@ -1776,7 +1772,8 @@ print_exception_recursive(PyObject *f, PyObject *value, PyObject *seen)
|
|||
cause_message, f);
|
||||
}
|
||||
}
|
||||
else if (context) {
|
||||
else if (context &&
|
||||
!((PyBaseExceptionObject *)value)->suppress_context) {
|
||||
res = PySet_Contains(seen, context);
|
||||
if (res == -1)
|
||||
PyErr_Clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue