In Python 3.12, quoting https://docs.python.org/dev/whatsnew/3.13.html
> PEP 667: The locals() builtin now has defined semantics when mutating the returned mapping. Python debuggers and similar tools may now more reliably update local variables in optimized scopes even during concurrent code execution.
with more details at https://docs.python.org/dev/whatsnew/3.13.html#whatsnew313-l... , which adds:
> To ensure debuggers and similar tools can reliably update local variables in scopes affected by this change, FrameType.f_locals now returns a write-through proxy to the frame’s local and locally referenced nonlocal variables in these scopes