Stepan Wagner added the comment:
Thank you, I wasn't paying attention enough. It works as you describe.
On Tue, Dec 4, 2012 at 9:46 PM, R. David Murray wrote:
>
> R. David Murray added the comment:
>
> The only way I was able to replicate that result was by removing the
> entire try/except bloc
R. David Murray added the comment:
The only way I was able to replicate that result was by removing the entire
try/except block, including the yield. In that case, wrap is no longer a
generator, so the exception is raised before you enter the for loop.
--
Stepan Wagner added the comment:
OK, thanks for explanation.
The behaviour is still strange, because when I delete try...except clause
from wrap, the StopIteration exc from emptygen terminates the program with
traceback.
On Tue, Dec 4, 2012 at 9:14 PM, R. David Murray wrote:
>
> R. David Murra
R. David Murray added the comment:
I don't see the bug here.
Your for loop calls wrap. Wrap calls emptygen. Emptygen raises a
StopIteration exception. That exception is of course propagated upward (it
isn't caught by wrap), and the loop stops.
--
nosy: +r.david.murray
resolution:
New submission from Stepan Wagner:
def emptygen():
# Or other more meaningful generator
raise StopIteration
yield
def wrap(gen):
next(gen)
print("This should be printed or StopIteration raised.")
while True:
try:
yield next(gen)
except StopIter