From b75e7dc60adcd4e06b13385cf8ccb84d14b0040c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 26 Jul 2006 22:26:55 +0000 Subject: Fix unsafe deletion of a dictionary item during iteration. svn path=/main/trunk/; revision=4026 --- pym/portage_util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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), -- cgit v1.2.3-1-g7c22