[Python-Dev] context manager - generator interaction?

2007-04-05 Thread Bob Sidebotham
The interaction shown below feels like a bug, or at least very much a trap for the unwary. It's some sort of interaction between a context manager and a generator, both of which can raise StopIteration. The code is excised from a real application, so it's a bit artificial looking. Nevertheless, it

Re: [Python-Dev] context manager - generator interaction?

2007-04-05 Thread Aahz
On Thu, Apr 05, 2007, Bob Sidebotham wrote: > > The interaction shown below feels like a bug, or at least very much a > trap for the unwary. Please go ahead and file a bug report on SourceForge -- that way there is a record. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraf

Re: [Python-Dev] context manager - generator interaction?

2007-04-05 Thread Guido van Rossum
Isn't this violating the rule that a try/except should only enclose the smallest expression where the exception is expected? BTW this is probably more appropriate for c.l.py -- even if there's a change to the language to come out of the discussion, it should be held there until the use case is wel

Re: [Python-Dev] context manager - generator interaction?

2007-04-05 Thread Phillip J. Eby
At 03:54 PM 4/5/2007 -0400, Bob Sidebotham wrote: >The interaction shown below feels like a bug, or at least very much a >trap for the unwary. It's some sort of interaction between a context >manager and a generator, both of which can raise StopIteration. The >code is excised from a real applicatio

Re: [Python-Dev] context manager - generator interaction?

2007-04-05 Thread Robert Brewer
Guido van Rossum wrote: > Isn't this violating the rule that a try/except should only enclose > the smallest expression where the exception is expected? Yeah, and I keep finding myself wanting to hyperlink to that "rule" in the official docs, but it only seems to be written down in developer's hea

Re: [Python-Dev] context manager - generator interaction?

2007-04-05 Thread Terry Reedy
"Robert Brewer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Guido van Rossum wrote: | > Isn't this violating the rule that a try/except should only enclose | > the smallest expression where the exception is expected? | | Yeah, and I keep finding myself wanting to hyperlink to th

Re: [Python-Dev] context manager - generator interaction?

2007-04-05 Thread Raymond Hettinger
> Guido van Rossum wrote: >> Isn't this violating the rule that a try/except should only enclose >> the smallest expression where the exception is expected? > > Yeah, and I keep finding myself wanting to hyperlink to that "rule" in > the official docs, but it only seems to be written down in devel