However, with the current expansion they are different. Only the version not using "yield from" will print "CLOSED" in this case:
g = outer() g.next() # prints 1 g.close() # should print "CLOSED", but doesn't because the GeneratorExit is reraised by yield-from
I currently don't think that a special case for GeneratorExit is needed. Can you give me an example showing that it is?
Take your example, replace the "print val" with a "yield val" and you get a broken generator that will yield again when close() is called. Generators that catch and do anything with GeneratorExit other than turn it into StopIteration are almost always going to be broken - the new expression needs to avoid making it easy to do that accidentally. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------