On Thu, Mar 8, 2012 at 10:32 AM, Jim J. Jewett <jimjjew...@gmail.com> wrote:
> How is this a problem?
>
> Re-entering a generator is a bug.  Python caught it and raised an
> appropriate exception.

No, the problem was that the interpreter screwed up the state of the
generators while attempting to deal with the erroneous reentry. The
ValueError *should* just be caught and completely suppressed by the
try/except block, but that wasn't quite happening properly - the
failed attempt at reentry left the generators in a dodgy state (which
is why the subsequent "3" was being produced, but then the expected
final "4" vanished into the electronic ether).

Benjamin figured out where the generator's reentrancy check was going
wrong, so Stefan's example should do the right thing in the next alpha
(i.e. the ValueError will still get raised and suppressed by the
try/except block, the inner generator will complete, but the outer
generator will also continue on to produce the final value).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to