Kaydet (Commit) 93149d93 authored tarafından Phillip J. Eby's avatar Phillip J. Eby

Minor clarity edit to contextlib per Guido's request.

üst 2ba96610
...@@ -31,11 +31,11 @@ class GeneratorContextManager(object): ...@@ -31,11 +31,11 @@ class GeneratorContextManager(object):
try: try:
self.gen.throw(type, value, traceback) self.gen.throw(type, value, traceback)
raise RuntimeError("generator didn't stop after throw()") raise RuntimeError("generator didn't stop after throw()")
except StopIteration: except StopIteration, exc:
# Suppress the exception *unless* it's the same exception that # Suppress the exception *unless* it's the same exception that
# was passed to throw(). This prevents a StopIteration # was passed to throw(). This prevents a StopIteration
# raised inside the "with" statement from being suppressed # raised inside the "with" statement from being suppressed
return sys.exc_info()[1] is not value return exc is not value
except: except:
# only re-raise if it's *not* the exception that was # only re-raise if it's *not* the exception that was
# passed to throw(), because __exit__() must not raise # passed to throw(), because __exit__() must not raise
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment