summaryrefslogtreecommitdiffstats
path: root/Lib/contextlib.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-08-23 18:11:33 (GMT)
committerGeorg Brandl <georg@python.org>2007-08-23 18:11:33 (GMT)
commitac4018ae392459b6866ada5d0792d143d2c7cebc (patch)
treea247a503fcd1e6b3eac74c779c6aa1a7e0b6ce1d /Lib/contextlib.py
parentadd36e5fdf2272c9f2c7fb9239bc4a6621e46d2d (diff)
downloadcpython-ac4018ae392459b6866ada5d0792d143d2c7cebc.zip
cpython-ac4018ae392459b6866ada5d0792d143d2c7cebc.tar.gz
cpython-ac4018ae392459b6866ada5d0792d143d2c7cebc.tar.bz2
Use try-except-finally in contextlib.
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r--Lib/contextlib.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index a807c42..4f83ef6 100644
--- a/Lib/contextlib.py
+++ b/Lib/contextlib.py
@@ -105,15 +105,14 @@ def nested(*managers):
vars = []
exc = (None, None, None)
try:
- try:
- for mgr in managers:
- exit = mgr.__exit__
- enter = mgr.__enter__
- vars.append(enter())
- exits.append(exit)
- yield vars
- except:
- exc = sys.exc_info()
+ for mgr in managers:
+ exit = mgr.__exit__
+ enter = mgr.__enter__
+ vars.append(enter())
+ exits.append(exit)
+ yield vars
+ except:
+ exc = sys.exc_info()
finally:
while exits:
exit = exits.pop()