mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
[3.6] Clarify exception handler scope in contextlib (GH-1103)
Moved explicit raise from inside try to try...else.
(cherry picked from commit 680e20beee
)
This commit is contained in:
parent
bc9025012f
commit
bd1173f202
1 changed files with 2 additions and 1 deletions
|
@ -98,7 +98,6 @@ class _GeneratorContextManager(ContextDecorator, AbstractContextManager):
|
|||
value = type()
|
||||
try:
|
||||
self.gen.throw(type, value, traceback)
|
||||
raise RuntimeError("generator didn't stop after throw()")
|
||||
except StopIteration as exc:
|
||||
# Suppress StopIteration *unless* it's the same exception that
|
||||
# was passed to throw(). This prevents a StopIteration
|
||||
|
@ -124,6 +123,8 @@ class _GeneratorContextManager(ContextDecorator, AbstractContextManager):
|
|||
#
|
||||
if sys.exc_info()[1] is not value:
|
||||
raise
|
||||
else:
|
||||
raise RuntimeError("generator didn't stop after throw()")
|
||||
|
||||
|
||||
def contextmanager(func):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue