RuntimeError in tracoverlayview/web_ui.py when iterating over MIME types with Python 2.7

11 views
Skip to first unread message

Maël

unread,
Jun 18, 2026, 5:08:54 AM (6 days ago) Jun 18
to Trac Users
Hello,

We encountered a runtime issue with the tracoverlayview plugin when running under Python 2.7.

The error is caused by iterating over a dictionary while it may be modified during the loop. In our case, the issue occurs in tracoverlayview/web_ui.py, in the _get_mimetypes() method:
for ext, mimetype in _iteritems(map_):

This can raise the following error:
RuntimeError: dictionary changed size during iteration

We applied the following local patch to iterate over a static list of items instead:
for ext, mimetype in list(_iteritems(map_)):

Suggested patch:
-            for ext, mimetype in _iteritems(map_):
+           for ext, mimetype in list(_iteritems(map_)):

This fixes the issue in our environment.
Thank you.

Jun Omae

unread,
Jun 18, 2026, 7:19:19 AM (5 days ago) Jun 18
to trac-...@googlegroups.com
Thanks for the reporting. But unable to reproduce the issue. Also,
very weird. The "map_" is not modified after initialized by Trac core
and mimetypes module. I don't believe the error is raised.

--
Jun Omae <jun...@gmail.com> (大前 潤)
Reply all
Reply to author
Forward
0 new messages