Fix for bug 1705170 - contextmanager swallowing StopIteration (2.5 backport candidate)

This commit is contained in:
Nick Coghlan 2007-11-02 10:09:12 +00:00
parent ac3d429edc
commit 3814a911aa
2 changed files with 21 additions and 0 deletions

View file

@ -25,6 +25,10 @@ class GeneratorContextManager(object):
else:
raise RuntimeError("generator didn't stop")
else:
if value is None:
# Need to force instantiation so we can reliably
# tell if we get the same exception back
value = type()
try:
self.gen.throw(type, value, traceback)
raise RuntimeError("generator didn't stop after throw()")