[Python-checkins] r57331 - python/trunk/Lib/contextlib.py

georg.brandl python-checkins at python.org
Thu Aug 23 20:11:33 CEST 2007


Author: georg.brandl
Date: Thu Aug 23 20:11:33 2007
New Revision: 57331

Modified:
   python/trunk/Lib/contextlib.py
Log:
Use try-except-finally in contextlib.


Modified: python/trunk/Lib/contextlib.py
==============================================================================
--- python/trunk/Lib/contextlib.py	(original)
+++ python/trunk/Lib/contextlib.py	Thu Aug 23 20:11:33 2007
@@ -105,15 +105,14 @@
     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()


More information about the Python-checkins mailing list