diff Lib/contextlib.py @ 43749:c4624dc0d41b legacy-trunk

Fix for bug 1705170 - contextmanager swallowing StopIteration (2.5 backport candidate)
author Nick Coghlan <ncoghlan@gmail.com>
date Fri, 02 Nov 2007 10:09:12 +0000
parents adb83f4ac4cb
children 1423834b72d8
line wrap: on
line diff
--- a/Lib/contextlib.py	Fri Nov 02 08:24:59 2007 +0000
+++ b/Lib/contextlib.py	Fri Nov 02 10:09:12 2007 +0000
@@ -25,6 +25,10 @@
             else:
                 raise RuntimeError("generator didn't stop")
         else:
+            if value is None:
+                # Need to force instantiation so we can reliably
+                # tell if we get the same exception back
+                value = type()
             try:
                 self.gen.throw(type, value, traceback)
                 raise RuntimeError("generator didn't stop after throw()")