diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-10-28 21:34:36 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-10-28 21:34:36 +0000 |
commit | 937a8e4399cdefc18b9a5ec7bcb6c0dda4502fb6 (patch) | |
tree | 7fec985aea2cd41a0b72428bf7d8867d3da402e8 | |
parent | b88012cf376443a75310a7ed971ea98934f80624 (diff) | |
download | portage-937a8e4399cdefc18b9a5ec7bcb6c0dda4502fb6.tar.gz portage-937a8e4399cdefc18b9a5ec7bcb6c0dda4502fb6.tar.bz2 portage-937a8e4399cdefc18b9a5ec7bcb6c0dda4502fb6.zip |
Fix PackageSet.getAtoms() and getNonAtoms() so that they
don't return references to private data structures.
svn path=/main/trunk/; revision=8335
-rw-r--r-- | pym/portage/sets/base.py | 16 |
1 files changed, 10 insertions, 6 deletions
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) |