]> granicus.if.org Git - python/commitdiff
More extensive comment on __exit__ handling, per Guido's request.
authorPhillip J. Eby <pje@telecommunity.com>
Sat, 25 Mar 2006 04:32:12 +0000 (04:32 +0000)
committerPhillip J. Eby <pje@telecommunity.com>
Sat, 25 Mar 2006 04:32:12 +0000 (04:32 +0000)
Lib/contextlib.py

index 282fc51004554476d685a264eee131b86c64d297..d329087c974e6b25a67374a2b424d73d0b6f8b90 100644 (file)
@@ -34,6 +34,13 @@ class GeneratorContextManager(object):
             except StopIteration:
                 return True
             except:
+                # only re-raise if it's *not* the exception that was
+                # passed to throw(), because __exit__() must not raise
+                # an exception unless __exit__() itself failed.  But throw()
+                # has to raise the exception to signal propagation, so this
+                # fixes the impedance mismatch between the throw() protocol
+                # and the __exit__() protocol.
+                #
                 if sys.exc_info()[1] is not value:
                     raise