summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-07-03 20:29:39 +0000
committerZac Medico <zmedico@gentoo.org>2009-07-03 20:29:39 +0000
commit4e1c248d9b02b1ef04ac5207af2625130d45c45c (patch)
tree6e24086fc924540f27f097d3603edb79925cfab4
parent0bab68e3df2061ce1f4d46a69e3ddeccd7199e0f (diff)
downloadportage-4e1c248d9b02b1ef04ac5207af2625130d45c45c.tar.gz
portage-4e1c248d9b02b1ef04ac5207af2625130d45c45c.tar.bz2
portage-4e1c248d9b02b1ef04ac5207af2625130d45c45c.zip
Implement LazyItemsDict.pop() since dict.pop() bypasses our overridden
__getitem__ implementation. This fixes a problem with config.setcpv() failing to set PORTAGE_REPO_NAME when appropriate. Thanks to Arfrever for reporting. svn path=/main/trunk/; revision=13767
-rw-r--r--pym/portage/util.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/pym/portage/util.py b/pym/portage/util.py
index c78c3b2f9..76e17e4ac 100644
--- a/pym/portage/util.py
+++ b/pym/portage/util.py
@@ -1122,6 +1122,23 @@ class LazyItemsDict(dict):
else:
return dict.__getitem__(self, item_key)
+ def pop(self, key, *args):
+ """
+ dict.pop() bypasses our overridden __getitem__ implementation, so we
+ also have to implement our own pop().
+ """
+ if len(args) > 1:
+ raise TypeError("pop expected at most 2 arguments, got " + \
+ repr(1 + len(args)))
+ try:
+ value = self[key]
+ except KeyError:
+ if args:
+ return args[0]
+ raise
+ del self[key]
+ return value
+
def __setitem__(self, item_key, value):
if item_key in self.lazy_items:
del self.lazy_items[item_key]