[Python-checkins] r43308 - python/trunk/Lib/contextlib.py
phillip.eby
python-checkins at python.org
Sat Mar 25 05:32:14 CET 2006
Author: phillip.eby
Date: Sat Mar 25 05:32:12 2006
New Revision: 43308
Modified:
python/trunk/Lib/contextlib.py
Log:
More extensive comment on __exit__ handling, per Guido's request.
Modified: python/trunk/Lib/contextlib.py
==============================================================================
--- python/trunk/Lib/contextlib.py (original)
+++ python/trunk/Lib/contextlib.py Sat Mar 25 05:32:12 2006
@@ -34,6 +34,13 @@
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
More information about the Python-checkins
mailing list