mirror of
https://github.com/python/cpython.git
synced 2025-09-14 04:37:29 +00:00
More extensive comment on __exit__ handling, per Guido's request.
This commit is contained in:
parent
e33901eb2b
commit
ccc7bb4ef2
1 changed files with 7 additions and 0 deletions
|
@ -34,6 +34,13 @@ class GeneratorContextManager(object):
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return True
|
return True
|
||||||
except:
|
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:
|
if sys.exc_info()[1] is not value:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue