def __exit__(self, *exc_details):
                # We manipulate the exception state so it behaves as though
                # we were actually nesting multiple with statements
                frame_exc = sys.exc_info()[1]
                def _fix_exception_context(new_exc, old_exc):
                    while 1:
                        exc_context = new_exc.__context__
                        if exc_context in (None, frame_exc):
                            break
                        new_exc = exc_context
                    new_exc.__context__ = old_exc
        
                # Callbacks are invoked in LIFO order to match the behaviour of
                # nested context managers
                suppressed_exc = False
                while self._exit_callbacks:
                    cb = self._exit_callbacks.pop()
                    try:
                        if cb(*exc_details):
                            suppressed_exc = True
                            exc_details = (None, None, None)
                    except:
                        new_exc_details = sys.exc_info()
                        # simulate the stack of exceptions by setting the context
                        _fix_exception_context(new_exc_details[1], exc_details[1])
                        if not self._exit_callbacks:
                            raise
                        exc_details = new_exc_details
                return suppressed_exc
dataset/ETHPy150Open enthought/traits/traits/_py2to3.py/ExitStack.__exit__/original