summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-11-27 02:08:03 +0000
committerZac Medico <zmedico@gentoo.org>2007-11-27 02:08:03 +0000
commit0c89454e0fbdbf6b0945eaf0f7540810dae7c1fe (patch)
treea3c7c633b420db5d369145408fa17e3b0ddf7787
parenta5adf03304d80696fb701e2373f13876bf9a50f8 (diff)
downloadportage-0c89454e0fbdbf6b0945eaf0f7540810dae7c1fe.tar.gz
portage-0c89454e0fbdbf6b0945eaf0f7540810dae7c1fe.tar.bz2
portage-0c89454e0fbdbf6b0945eaf0f7540810dae7c1fe.zip
Fix config.pop() so that is will properly raise a KeyError.
svn path=/main/trunk/; revision=8704
-rw-r--r--pym/portage/__init__.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 79e559d69..c66a1ab33 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -2470,11 +2470,18 @@ class config(object):
return d[k]
return x
- def pop(self, k, x=None):
- self.modifying()
- v = x
+ def pop(self, key, *args):
+ if len(args) > 1:
+ raise TypeError(
+ "pop expected at most 2 arguments, got " + \
+ repr(1 + len(args)))
+ v = self
for d in reversed(self.lookuplist):
- v = d.pop(k, v)
+ v = d.pop(key, v)
+ if v is self:
+ if args:
+ return args[0]
+ raise KeyError(key)
return v
def has_key(self,mykey):