<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, 3 Oct 2018 at 19:39, Benjamin Peterson <<a href="mailto:benjamin@python.org">benjamin@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On Wed, Oct 3, 2018, at 08:59, Steven D'Aprano wrote:<br>
> On the bug tracker, there's a discussion about the current behaviour of <br>
> the assert statement, where shadowing AssertionError will change the <br>
> behaviour of the assertion.<br>
> <br>
> <a href="https://bugs.python.org/issue34880" rel="noreferrer" target="_blank">https://bugs.python.org/issue34880</a><br>
> <br>
> Currently, assert does a LOAD_GLOBAL on AssertionError, which means if <br>
> you shadow the name, you get a different exception. This behaviour goes <br>
> back to Python 1.5.<br>
> <br>
> I'm looking for guidance here, is this the intended behaviour, or an <br>
> accident? Should it be changed to better match other builtins?<br>
<br>
The behavior certainly has been relied on historically by py.test. By replacing builtins.AssertionError, you can improve the error message of the AssertionError by, e.g., inspecting the failing frame. py.test's code to do this was deleted in 2016, but other code bases may still be relying on this hack. It's probably okay to change the behavior in 3.8 with the understanding that a revert may be necessary if some clever hack surfaces.<br></blockquote><div><br></div><div>I like Guido's reasoning that syntax probably shouldn't be affected by overloads unless otherwise documented as so, and Benjamin's approach to solving it for 3.8 and then potentially reverting if it breaks too much.<br></div><div><br></div><div>-Brett<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/brett%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/brett%40python.org</a><br>
</blockquote></div></div>