Fix SetConfig.getSetAtoms() to stop initializing ignorelist
authorZac Medico <zmedico@gentoo.org>
Sun, 28 Oct 2007 20:30:46 +0000 (20:30 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 28 Oct 2007 20:30:46 +0000 (20:30 -0000)
in the parameter list since otherwise the ignorelist persists
between calls and causes unpredictable results for callers.

svn path=/main/trunk/; revision=8333

pym/portage/sets/__init__.py

index 9f562820b4dcb59870d0854707ee96555d0ee57b..940aa10204da6be927627b1bdf26fd7a6202e0f6 100644 (file)
@@ -94,14 +94,17 @@ class SetConfig(SafeConfigParser):
                        self.aliases = shortnames
                return self.aliases
 
-       def getSetAtoms(self, setname, ignorelist=[]):
+       def getSetAtoms(self, setname, ignorelist=None):
                myset = self.getSetsWithAliases()[setname]
                myatoms = myset.getAtoms()
-               ignorelist.append(setname)
+               if ignorelist is None:
+                       ignorelist = set()
+               ignorelist.add(setname)
                for n in myset.getNonAtoms():
                        if n[0] == SETPREFIX and n[1:] in self.aliases:
                                if n[1:] not in ignorelist:
-                                       myatoms.update(self.getSetAtoms(n[1:]))
+                                       myatoms.update(self.getSetAtoms(n[1:],
+                                               ignorelist=ignorelist))
                return myatoms
 
 def make_default_config(settings, trees):