◐ Shell
clean mode source ↗

gh-103865: add monitoring support to LOAD_SUPER_ATTR by carljm · Pull Request #103866 · python/cpython

What is the super = super assignment testing?
By setting the global variable super to the builtin super, nothing changes.

The compiler checks for statically visible shadowing of the name super, and declines to emit LOAD_SUPER_ATTR at all if shadowing is found. So super = super does change something; it prevents LOAD_SUPER_ATTR from occurring in the bytecode.

This is useful for these tests because it allows me to verify that the monitoring events emitted are identical for LOAD_SUPER_ATTR as they would have been for the old-style LOAD_GLOBAL super; CALL; LOAD_ATTR form.

I think you need to set super to something that isn't super for it to be a useful test.

I don't currently have any tests here in test_monitoring.py that dynamically shadow super (such that we have LOAD_SUPER_ATTR but with a non-standard super). But I don't think such tests are really useful here, since whether super is dynamically shadowed or not doesn't actually change the (non-specialized) implementation of LOAD_SUPER_ATTR at all. (I do have such tests in test_super.py, for checking correctness.)