<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 16 October 2017 at 21:08, Juancarlo Añez <span dir="ltr"><<a href="mailto:apalala@gmail.com" target="_blank">apalala@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Interestingly, thinking about the problem in terms of exception handling flow reminded me of the fact that having a generator-iterator yield while inside a with statement or try/except block is already considered an anti-pattern in many situations, precisely because it means that any exceptions that get thrown in (including GeneratorExit) will be intercepted when that may not be what the author really intended.</div><div class="gmail_quote"><br></div></div></div></blockquote><div><br></div></span><div>It all works fine now: </div><div><br></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><a href="https://github.com/neogeny/TatSu/blob/master/tatsu/contexts.py" target="_blank">https://github.com/neogeny/<wbr>TatSu/blob/master/tatsu/<wbr>contexts.py</a></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>So, I have a strong requirement: whatever is decided on this PEP... </div><div><br></div><div>Please don't break it? (or make it illegal) </div></div></div></div></blockquote><div><br></div>The "anti-pattern in many situations" qualifier was there because there are cases where it's explicitly expected to work, and isn't an anti-pattern at all (e.g. when the generator is decorated with contextlib.contextmanager, or when you're using a context manager to hold open an external resource like a file until the generator is closed).</div></div><div class="gmail_extra"><br></div><div class="gmail_extra">So this wasn't intended as an argument for changing anything - rather, it's about my changing my perspective on how beneficial it would be to have generators default to maintaining their own distinct logical context (which then becomes an argument for *not* changing anything).<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Cheers,</div><div class="gmail_extra">Nick.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia</div>
</div></div>