Issue 1658: "RuntimeError: dictionary changed size during iteration" in Tkinter (original) (raw)

Created on 2007-12-19 13:08 by quentin.gallet-gilles, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tkinter_dictkeys.patch quentin.gallet-gilles,2007-12-19 13:08
tkinter_issue1658.diff gpolo,2008-05-30 02:14
Messages (8)
msg58805 - (view) Author: Quentin Gallet-Gilles (quentin.gallet-gilles) Date: 2007-12-19 13:08
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 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 ?
msg58815 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-12-19 17:48
Yes, it sounds like a good idea. The patch should be applied to 2.6.
msg67517 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-05-30 02:14
There is this same problem at scrolledtext.py (new name). I'm attaching a patch that is a bit different that correct both cases.
msg72428 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-09-03 22:46
Can someone review the patch and apply please ? It is sad to leave tkinter like this in py3k. Clearly there are not much people using it there, but it is something very simple to fix.
msg72487 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-04 07:32
The patch is indeed simple. A minor stylistic remark: instead of for c in classes: del cnf[c[0]] it would be clearer to write for k, v in classes: del cnf[v] like the other loop does, 3 lines after. Please apply.
msg72492 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-09-04 11:24
Committed r66215 I've applied this only in py3k since it doesn't affect python 2.6
msg97419 - (view) Author: Sridhar Ratnakumar (srid) Date: 2010-01-08 17:26
I get this error while running Python 2.6.4 tests (on 64-bit Linux box) test_urllib test test_urllib failed -- Traceback (most recent call last): File "/home/apy/rrun/tmp/autotest/apy/lib/python2.6/test/test_urllib.py", line 104, in setUp for k, v in os.environ.iteritems(): RuntimeError: dictionary changed size during iteration Should open a new bug?
msg97422 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-08 17:50
> test_urllib > test test_urllib failed -- Traceback (most recent call last): > File "/home/apy/rrun/tmp/autotest/apy/lib/python2.6/test/test_urllib.py", line 104, in setUp > for k, v in os.environ.iteritems(): > RuntimeError: dictionary changed size during iteration I reopened for this one.
History
Date User Action Args
2022-04-11 14:56:29 admin set github: 45999
2010-01-08 17:50:42 flox set nosy: + floxmessages: +
2010-01-08 17:26:15 srid set nosy: + sridmessages: +
2008-09-04 11:24:16 gpolo set status: open -> closedresolution: accepted -> fixedmessages: + versions: - Python 2.6
2008-09-04 07:32:36 amaury.forgeotdarc set keywords: - needs reviewnosy: + amaury.forgeotdarcmessages: +
2008-09-03 22:46:16 gpolo set keywords: + needs reviewmessages: +
2008-08-24 22:23:09 nnorwitz set type: crash -> behavior
2008-05-30 02:14:10 gpolo set files: + tkinter_issue1658.diffnosy: + gpolomessages: +
2007-12-24 03:52:34 kbk set nosy: + kbk
2007-12-19 17:48:07 christian.heimes set versions: + Python 2.6nosy: + christian.heimesmessages: + priority: normalkeywords: + patchresolution: accepted
2007-12-19 13:08:17 quentin.gallet-gilles create