Fix contextlib.nested to cope with exit methods raising and handling exceptions

This commit is contained in:
Nick Coghlan 2006-04-24 04:37:15 +00:00
parent 27ec1a773c
commit da2268feec
3 changed files with 33 additions and 1 deletions

View file

@ -127,7 +127,10 @@ def nested(*contexts):
except:
exc = sys.exc_info()
if exc != (None, None, None):
raise
# Don't rely on sys.exc_info() still containing
# the right information. Another exception may
# have been raised and caught by an exit method
raise exc[0], exc[1], exc[2]
@contextmanager