summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-05-14 22:09:31 -0700
committerBenjamin Peterson <benjamin@python.org>2012-05-14 22:09:31 -0700
commit9031c8f35aa4af460cb1507b2fc1ec8f78601327 (patch)
treec53500e8e81db30516cb33256826a8123b7dd0b1 /Python/pythonrun.c
parentf3ad80b549fdea8ed1977bc0b7711b50ee87ecb2 (diff)
downloadcpython-9031c8f35aa4af460cb1507b2fc1ec8f78601327.tar.gz
PEP 415: Implement suppression of __context__ display with an exception attribute
This replaces the original PEP 409 implementation. See #14133.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index cd3cf5c53c..d9eb5e7d9f 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -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();