From: Zac Medico Date: Wed, 26 Jul 2006 22:26:55 +0000 (-0000) Subject: Fix unsafe deletion of a dictionary item during iteration. X-Git-Tag: v2.1.1~139 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b75e7dc60adcd4e06b13385cf8ccb84d14b0040c;p=portage.git Fix unsafe deletion of a dictionary item during iteration. svn path=/main/trunk/; revision=4026 --- 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),