diff options
author | amosonn <amosonn@gmail.com> | 2017-03-01 06:18:27 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2017-03-01 06:18:27 (GMT) |
commit | 680e20beee8bbce9f857b8e7795009191f98b0ba (patch) | |
tree | 5ae14f35caa06e019eb9f81230400be848550a68 /Lib/contextlib.py | |
parent | eca52296da65ccbe5b5926451453769ce4a069c3 (diff) | |
download | cpython-680e20beee8bbce9f857b8e7795009191f98b0ba.zip cpython-680e20beee8bbce9f857b8e7795009191f98b0ba.tar.gz cpython-680e20beee8bbce9f857b8e7795009191f98b0ba.tar.bz2 |
Clarify exception handler scope in contextlib
Moved explicit raise from inside try to try...else.
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r-- | Lib/contextlib.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py index 84219685..e91cf46 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -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): |