diff options
author | Mariatta <Mariatta@users.noreply.github.com> | 2017-04-13 04:05:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 04:05:25 (GMT) |
commit | c0f4240fac397e1cdd1ee202fc1ce6eb23037d06 (patch) | |
tree | dcf147d90a9359c29bb1e7c98376e261fb6f0de7 | |
parent | f3972dd1c1c514ed26bb8139b59b649fa7983743 (diff) | |
download | cpython-c0f4240fac397e1cdd1ee202fc1ce6eb23037d06.zip cpython-c0f4240fac397e1cdd1ee202fc1ce6eb23037d06.tar.gz cpython-c0f4240fac397e1cdd1ee202fc1ce6eb23037d06.tar.bz2 |
[3.5] Clarify exception handler scope in contextlib (GH-1104)
Moved explicit raise from inside try to try...else.
(cherry picked from commit 680e20beee8bbce9f857b8e7795009191f98b0ba)
-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 4a7bd07..c018895 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -75,7 +75,6 @@ class _GeneratorContextManager(ContextDecorator): 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 @@ -101,6 +100,8 @@ class _GeneratorContextManager(ContextDecorator): # if sys.exc_info()[1] is not value: raise + else: + raise RuntimeError("generator didn't stop after throw()") def contextmanager(func): |