summaryrefslogtreecommitdiffstats
path: root/Lib/contextlib.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2006-04-24 04:37:15 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2006-04-24 04:37:15 (GMT)
commitda2268feecd4b956161ed7fdd05da125606189cc (patch)
tree0e387c87ccb58228c8030ad7951db225e0a13ec1 /Lib/contextlib.py
parent27ec1a773c92b6a9a144a45334ce2b38ae6118b6 (diff)
downloadcpython-da2268feecd4b956161ed7fdd05da125606189cc.zip
cpython-da2268feecd4b956161ed7fdd05da125606189cc.tar.gz
cpython-da2268feecd4b956161ed7fdd05da125606189cc.tar.bz2
Fix contextlib.nested to cope with exit methods raising and handling exceptions
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r--Lib/contextlib.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index aa5335d..157b4cc 100644
--- a/Lib/contextlib.py
+++ b/Lib/contextlib.py
@@ -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