diff -r cf9c379a9859 Lib/contextlib.py --- a/Lib/contextlib.py Fri Jun 01 09:48:37 2012 +0300 +++ b/Lib/contextlib.py Fri Jun 01 10:57:08 2012 +0300 @@ -236,9 +236,8 @@ exc_details = (None, None, None) except: new_exc_details = sys.exc_info() - if exc_details != (None, None, None): - # simulate the stack of exceptions by setting the context - new_exc_details[1].__context__ = exc_details[1] + # simulate the stack of exceptions by setting the context + new_exc_details[1].__context__ = exc_details[1] if not self._exit_callbacks: raise exc_details = new_exc_details diff -r cf9c379a9859 Lib/test/test_contextlib.py --- a/Lib/test/test_contextlib.py Fri Jun 01 09:48:37 2012 +0300 +++ b/Lib/test/test_contextlib.py Fri Jun 01 10:57:08 2012 +0300 @@ -553,12 +553,8 @@ except IndexError as exc: self.assertIsInstance(exc.__context__, KeyError) self.assertIsInstance(exc.__context__.__context__, AttributeError) - # Inner exceptions were suppressed, but the with statement - # cleanup code adds the one from the body back in as the - # context of the exception raised by the outer callbacks - # See http://bugs.python.org/issue14969 - suite_exc = exc.__context__.__context__.__context__ - self.assertIsInstance(suite_exc, ZeroDivisionError) + # suppressing the ValueError also means suppressing the ZeroDivisionError + self.assertIsNone(exc.__context__.__context__.__context__) else: self.fail("Expected IndexError, but no exception was raised") # Check the inner exceptions