From: Phillip J. Eby Date: Sat, 25 Mar 2006 04:32:12 +0000 (+0000) Subject: More extensive comment on __exit__ handling, per Guido's request. X-Git-Tag: v2.5a0~102 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ccc7bb4ef296fecb01c4cc7266dd0ca95151e893;p=thirdparty%2FPython%2Fcpython.git More extensive comment on __exit__ handling, per Guido's request. --- diff --git a/Lib/contextlib.py b/Lib/contextlib.py index 282fc5100455..d329087c974e 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -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