[Python-Dev] Should assert continue to do a LOAD_GLOBAL on AssertionError?

Guido van Rossum guido at python.org
Wed Oct 3 13:15:03 EDT 2018


Feels like an accident to me. Generally syntactic constructs should be
unaffected by what's in any namespace except when the override is
intentional (e.g. __import__).

On Wed, Oct 3, 2018 at 9:02 AM Steven D'Aprano <steve at pearwood.info> wrote:

> On the bug tracker, there's a discussion about the current behaviour of
> the assert statement, where shadowing AssertionError will change the
> behaviour of the assertion.
>
> https://bugs.python.org/issue34880
>
> Currently, assert does a LOAD_GLOBAL on AssertionError, which means if
> you shadow the name, you get a different exception. This behaviour goes
> back to Python 1.5.
>
> I'm looking for guidance here, is this the intended behaviour, or an
> accident? Should it be changed to better match other builtins?
>
> (For example, shadowing iter doesn't effect for loops.)
>
>
> Thanks,
>
>
> Steve
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>


-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20181003/e4dd9674/attachment.html>


More information about the Python-Dev mailing list