[issue1658] "RuntimeError: dictionary changed size during iteration" in Tkinter

Quentin Gallet-Gilles report at bugs.python.org
Wed Dec 19 14:08:17 CET 2007


New submission from Quentin Gallet-Gilles:

While investigating for the stdlib reorg of Tkinter, I came across the
following error:

~/dev/py3k$ ./python Lib/lib-tk/Dialog.py 
Traceback (most recent call last):
  File "Lib/lib-tk/Dialog.py", line 45, in <module>
    Pack: {}})
  File "/home/quentin/dev/py3k/Lib/lib-tk/Tkinter.py", line 1996, in
__init__
    Widget.__init__(self, master, 'button', cnf, kw)
  File "/home/quentin/dev/py3k/Lib/lib-tk/Tkinter.py", line 1921, in
__init__
    for k in cnf.keys():
RuntimeError: dictionary changed size during iteration


The attached patch adds list() around the dict.keys() call.

On a related note, this doesn't appear to be an isolated error, since a
similar issue (#1649) was recently fixed in r59554. Would it be a good
idea to look for other identical cases ?

----------
components: Tkinter
files: tkinter_dictkeys.patch
messages: 58805
nosy: quentin.gallet-gilles
severity: normal
status: open
title: "RuntimeError: dictionary changed size during iteration" in Tkinter
type: crash
versions: Python 3.0
Added file: http://bugs.python.org/file8995/tkinter_dictkeys.patch

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1658>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tkinter_dictkeys.patch
Type: text/x-patch
Size: 485 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-bugs-list/attachments/20071219/4b436496/attachment.bin 


More information about the Python-bugs-list mailing list