]> granicus.if.org Git - python/commitdiff
Issue #1658: dict size is changing during iteration in tkinter.BaseWidget and
authorGuilherme Polo <ggpolo@gmail.com>
Thu, 4 Sep 2008 11:21:31 +0000 (11:21 +0000)
committerGuilherme Polo <ggpolo@gmail.com>
Thu, 4 Sep 2008 11:21:31 +0000 (11:21 +0000)
tkinter.scrolledtext.ScrolledText.

Reviewed by Amaury Forgeot d'Arc

Lib/tkinter/__init__.py
Lib/tkinter/scrolledtext.py
Misc/NEWS

index faca78ff3ec3adf84f0eb2c33711305b650c9713..bb014b3578eae0d54cddd3885969770d1a41244b 100644 (file)
@@ -1913,11 +1913,9 @@ class BaseWidget(Misc):
             cnf = _cnfmerge((cnf, kw))
         self.widgetName = widgetName
         BaseWidget._setup(self, master, cnf)
-        classes = []
-        for k in cnf.keys():
-            if isinstance(k, type):
-                classes.append((k, cnf[k]))
-                del cnf[k]
+        classes = [(k, v) for k, v in cnf.items() if isinstance(k, type)]
+        for k, v in classes:
+            del cnf[k]
         self.tk.call(
             (widgetName, self._w) + extra + self._options(cnf))
         for k, v in classes:
index 084c3bfeb8b35fdb510c80cbdfe68fd13156b090..35767e669b9844113ec6e86fbb2fd958ba3d2723 100644 (file)
@@ -19,11 +19,10 @@ class ScrolledText(Text):
             cnf = {}
         if kw:
             cnf = _cnfmerge((cnf, kw))
-        fcnf = {}
-        for k in cnf.keys():
-            if isinstance(k, type) or k == 'name':
-                fcnf[k] = cnf[k]
-                del cnf[k]
+        fcnf = {k:v for k,v in cnf.items() if isinstance(k,type) or k=='name'}
+        for k in fcnf.keys():
+            del cnf[k]
+
         self.frame = Frame(master, **fcnf)
         self.vbar = Scrollbar(self.frame, name='vbar')
         self.vbar.pack(side=RIGHT, fill=Y)
index 3e77aa2d76d0f95bf29801cde0fdf8ba00ec1719..9bd063bc8dc41a54c4c2ade3f7cc76e05c5763c7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -77,6 +77,9 @@ C API
 Library
 -------
 
+- Issue #1658: tkinter changes dict size during iteration in both
+    tkinter.BaseWidget and tkinter.scrolledtext.ScrolledText.
+
 - The bsddb module (and therefore the dbm.bsd module) has been removed.
   It is now maintained outside of the standard library at
   http://www.jcea.es/programacion/pybsddb.htm.