summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-07-26 22:26:55 +0000
committerZac Medico <zmedico@gentoo.org>2006-07-26 22:26:55 +0000
commitb75e7dc60adcd4e06b13385cf8ccb84d14b0040c (patch)
tree61565fdf3233b4b14e4464275e5ddf706d2f07bb
parent4ab7d27f7b50b6d9f67b72f927db542813cd15c3 (diff)
downloadportage-b75e7dc60adcd4e06b13385cf8ccb84d14b0040c.tar.gz
portage-b75e7dc60adcd4e06b13385cf8ccb84d14b0040c.tar.bz2
portage-b75e7dc60adcd4e06b13385cf8ccb84d14b0040c.zip
Fix unsafe deletion of a dictionary item during iteration.
svn path=/main/trunk/; revision=4026
-rw-r--r--pym/portage_util.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pym/portage_util.py b/pym/portage_util.py
index b1974b543..a0385323d 100644
--- a/pym/portage_util.py
+++ b/pym/portage_util.py
@@ -166,7 +166,10 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0):
def grabdict_package(myfilename, juststrings=0, recursive=0):
pkgs=grabdict(myfilename, juststrings, empty=1, recursive=recursive)
- for x in pkgs:
+ # We need to call keys() here in order to avoid the possibility of
+ # "RuntimeError: dictionary changed size during iteration"
+ # when an invalid atom is deleted.
+ for x in pkgs.keys():
if not isvalidatom(x):
del(pkgs[x])
writemsg("--- Invalid atom in %s: %s\n" % (myfilename, x),