diff options
author | Georg Brandl <georg@python.org> | 2007-08-23 18:11:33 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-08-23 18:11:33 (GMT) |
commit | ac4018ae392459b6866ada5d0792d143d2c7cebc (patch) | |
tree | a247a503fcd1e6b3eac74c779c6aa1a7e0b6ce1d /Lib/contextlib.py | |
parent | add36e5fdf2272c9f2c7fb9239bc4a6621e46d2d (diff) | |
download | cpython-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.py | 17 |
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() |