diff Python/pythonrun.c @ 76942:b0eb7d2a9542

PEP 415: Implement suppression of __context__ display with an exception attribute This replaces the original PEP 409 implementation. See #14133.
author Benjamin Peterson <benjamin@python.org>
date Mon, 14 May 2012 22:09:31 -0700
parents eb68502731dd
children c3616595dada
line wrap: on
line diff
--- a/Python/pythonrun.c	Mon May 14 22:19:10 2012 -0400
+++ b/Python/pythonrun.c	Mon May 14 22:09:31 2012 -0700
@@ -1761,11 +1761,7 @@
         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 @@
                         cause_message, f);
                 }
             }
-            else if (context) {
+            else if (context &&
+                !((PyBaseExceptionObject *)value)->suppress_context) {
                 res = PySet_Contains(seen, context);
                 if (res == -1)
                     PyErr_Clear();