<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Jan 6, 2019 at 9:40 AM Paul G <<a href="mailto:paul@ganssle.io">paul@ganssle.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>I am not familiar enough with the compiler logic, but would it be possible to optimize this away by detecting whether the bound name has already been deleted during the body of the except statement?<br></div></blockquote><div><br></div><div>As was said before, it's not useful to optimize code that only runs on an exception. (Though if there was a <br></div><div><br><div class="gmail_quote">On January 6, 2019 4:18:00 PM UTC, Chris Angelico <<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>> wrote:<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<pre class="gmail-m_8397336809792651096k9mail">On Mon, Jan 7, 2019 at 3:13 AM Paul G <<a href="mailto:paul@ganssle.io" target="_blank">paul@ganssle.io</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 1ex 0.8ex;border-left:1px solid rgb(114,159,207);padding-left:1ex"><br> I think Serhiy is saying that if you delete exc before the except body ends, when the compiled code goes to delete it it will fail. Binding to None guarantees that there is something to delete.<br></blockquote><br>Ahh! Thank you. I interpreted that example as a "this is what it<br>compiles to", rather than actual source code that might fail. Can we<br>get this example, suitably annotated, into the documentation<br>somewhere?<br clear="all"></pre></blockquote><div><br></div><div>I don't see a reason to document this behavior -- it would be strange if it *didn't* work.</div><div><br></div><div>If we had an opcode to delete a variable but didn't raise if it is unset, we could use that, but otherwise I see no action needed here.<br></div></div></div></div><br>-- <br><div dir="ltr" class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div></div>