diff options
author | Phillip J. Eby <pje@telecommunity.com> | 2006-04-03 20:05:05 (GMT) |
---|---|---|
committer | Phillip J. Eby <pje@telecommunity.com> | 2006-04-03 20:05:05 (GMT) |
commit | 9444bd51c46a34410e92560e8f96ab75bd9eb332 (patch) | |
tree | f439b7e2658f49e350f1c5e4fc33862265b0368d /Lib/contextlib.py | |
parent | 9161a0d8da0ea3d8159ceed0d0bdb9e85e52e448 (diff) | |
download | cpython-9444bd51c46a34410e92560e8f96ab75bd9eb332.zip cpython-9444bd51c46a34410e92560e8f96ab75bd9eb332.tar.gz cpython-9444bd51c46a34410e92560e8f96ab75bd9eb332.tar.bz2 |
Fix SF#1462485: StopIteration raised in body of 'with' statement suppressed
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r-- | Lib/contextlib.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py index 9c00ef0..c26e27e 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -32,7 +32,9 @@ class GeneratorContextManager(object): self.gen.throw(type, value, traceback) raise RuntimeError("generator didn't stop after throw()") except StopIteration: - return True + # Supress the exception unless it's the same exception the + # was passed to throw(). + return sys.exc_info()[1] is not value except: # only re-raise if it's *not* the exception that was # passed to throw(), because __exit__() must not raise |