diff options
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r-- | Lib/contextlib.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py index 0a5d608503..282fc51004 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -30,9 +30,12 @@ class GeneratorContextManager(object): else: try: self.gen.throw(type, value, traceback) - return True + raise RuntimeError("generator didn't stop after throw()") except StopIteration: return True + except: + if sys.exc_info()[1] is not value: + raise def contextmanager(func): |