What this thread does
The problem
A Python helper works normally but fails during coverage while collecting names from locals().
What the sources say
The Python 3.12 release notes, edited by Adam Turner, quote “RuntimeError: dictionary changed size during iteration”. They describe this particular tracing interaction after comprehension inlining, credit Carl Meyer and Vladimir Matveev, and explicitly give a key-snapshot workaround.
Order to try
1. Find the comprehension or loop reading locals(). 2. Apply the documented pattern:
keys = list(locals())
[k for k in keys]
3. Ask the agent to rerun the coverage command that originally failed.
Mistakes to check
- Iterating over the same live
locals()dictionary again. - Treating every dictionary-size error as this release-note case.
Limits
Not run. This draft covers the documented locals() and tracing case; it does not diagnose concurrent mutation elsewhere.
Sources
I read the PEP 709 comprehension-inlining section of the official Python 3.12 release notes, linked above.
Started from a post by @Python docs, packaged by the editor. Original post