Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 76939:6ff172db8114 | 76942:b0eb7d2a9542 |
|---|---|
| 1759 if (PySet_Add(seen, value) == -1) | 1759 if (PySet_Add(seen, value) == -1) |
| 1760 PyErr_Clear(); | 1760 PyErr_Clear(); |
| 1761 else if (PyExceptionInstance_Check(value)) { | 1761 else if (PyExceptionInstance_Check(value)) { |
| 1762 cause = PyException_GetCause(value); | 1762 cause = PyException_GetCause(value); |
| 1763 context = PyException_GetContext(value); | 1763 context = PyException_GetContext(value); |
| 1764 if (cause && cause == Py_None) { | 1764 if (cause) { |
| 1765 /* print neither cause nor context */ | |
| 1766 ; | |
| 1767 } | |
| 1768 else if (cause) { | |
| 1769 res = PySet_Contains(seen, cause); | 1765 res = PySet_Contains(seen, cause); |
| 1770 if (res == -1) | 1766 if (res == -1) |
| 1771 PyErr_Clear(); | 1767 PyErr_Clear(); |
| 1772 if (res == 0) { | 1768 if (res == 0) { |
| 1773 print_exception_recursive( | 1769 print_exception_recursive( |
| 1774 f, cause, seen); | 1770 f, cause, seen); |
| 1775 err |= PyFile_WriteString( | 1771 err |= PyFile_WriteString( |
| 1776 cause_message, f); | 1772 cause_message, f); |
| 1777 } | 1773 } |
| 1778 } | 1774 } |
| 1779 else if (context) { | 1775 else if (context && |
| 1776 !((PyBaseExceptionObject *)value)->suppress_context) { | |
| 1780 res = PySet_Contains(seen, context); | 1777 res = PySet_Contains(seen, context); |
| 1781 if (res == -1) | 1778 if (res == -1) |
| 1782 PyErr_Clear(); | 1779 PyErr_Clear(); |
| 1783 if (res == 0) { | 1780 if (res == 0) { |
| 1784 print_exception_recursive( | 1781 print_exception_recursive( |
