Consider this code:
Set a breakpoint at
and run it. The Locals window shows two entries; one for
, and one for
. It should only show one for
It happens because the debugger tries to determine any global variables that are used by local frames and include them in the output. It does so by looking at co_names, but co_names includes all names used in the frame, not just variable names. It needs to
intersect co_names with globals, and only show those names which are present in both - it's still not 100% accurate, but close enough.