From: Zac Medico Date: Sun, 28 Oct 2007 21:34:36 +0000 (-0000) Subject: Fix PackageSet.getAtoms() and getNonAtoms() so that they X-Git-Tag: v2.2_pre1~488 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=937a8e4399cdefc18b9a5ec7bcb6c0dda4502fb6;p=portage.git Fix PackageSet.getAtoms() and getNonAtoms() so that they don't return references to private data structures. svn path=/main/trunk/; revision=8335 --- diff --git a/pym/portage/sets/base.py b/pym/portage/sets/base.py index c22ee9953..8e5863cba 100644 --- a/pym/portage/sets/base.py +++ b/pym/portage/sets/base.py @@ -26,7 +26,8 @@ class PackageSet(object): self._nonatoms = set() def __contains__(self, atom): - return atom in self.getAtoms() or atom in self._nonatoms + self._load() + return atom in self._atoms or atom in self._nonatoms def __iter__(self): for x in self.getAtoms(): @@ -36,18 +37,21 @@ class PackageSet(object): if not op in OPERATIONS: raise ValueError(op) return op in self._operations - - def getAtoms(self): + + def _load(self): if not (self._loaded or self._loading): self._loading = True self.load() self._loaded = True self._loading = False - return self._atoms + + def getAtoms(self): + self._load() + return self._atoms.copy() def getNonAtoms(self): - self.getAtoms() - return self._nonatoms + self._load() + return self._nonatoms.copy() def _setAtoms(self, atoms): atoms = map(str.strip, atoms)