Created
May 30, 2012 18:38
-
-
Save alonho/2838190 to your computer and use it in GitHub Desktop.
ExitStack.__exit__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __exit__(self, *exc_details): | |
if not self._exit_callbacks: | |
return | |
for cb in reversed(self._exit_callbacks): | |
try: | |
supress_exc = cb(*exc_details) | |
except: | |
exc_details = sys.exc_info() | |
else: | |
if supress_exc: | |
exc_details = (None, None, None) | |
self._exit_callbacks = deque() | |
return supress_exc or exc_details == (None, None, None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment