summaryrefslogtreecommitdiff
path: root/Lib/contextlib.py
diff options
context:
space:
mode:
authorPhillip J. Eby <pje@telecommunity.com>2006-03-25 04:32:12 +0000
committerPhillip J. Eby <pje@telecommunity.com>2006-03-25 04:32:12 +0000
commitccc7bb4ef296fecb01c4cc7266dd0ca95151e893 (patch)
treef0f7dfb2748012bd49026c55057ebbc855e610d4 /Lib/contextlib.py
parente33901eb2b196149eab06f2943256e07b494fbb1 (diff)
downloadcpython-git-ccc7bb4ef296fecb01c4cc7266dd0ca95151e893.tar.gz
More extensive comment on __exit__ handling, per Guido's request.
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r--Lib/contextlib.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index 282fc51004..d329087c97 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