GH-93143: Don't turn `LOAD_FAST` into `LOAD_FAST_CHECK` by brandtbucher · Pull Request #99075 · python/cpython
There are two cases when we need to set locals to None.
- Deletion of locals
- Jumping to arbitrary code
In the first case we can set the local to None and issue the warning cheaply and probably correctly. That's fine.
However when jumping, trying to decide which locals need to be set to None is going to be complex, expensive and error prone.
So I think we should go with @sweeneyde suggestion of setting all the undefined local variables to None.
Either don't issue any warning (as it might be confusing), or maybe issue a generic warning only if any locals were set to None.