diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-11-27 02:08:53 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-11-27 02:08:53 +0000 |
commit | 31c4e5832a8dc79fdba7308459444fd654a104e4 (patch) | |
tree | 71bd7ba76709ec387d839c6cd7eecdb752400bd0 | |
parent | 4ea80a0241e6b6ceac36cf8d92602befa6713fd7 (diff) | |
download | portage-31c4e5832a8dc79fdba7308459444fd654a104e4.tar.gz portage-31c4e5832a8dc79fdba7308459444fd654a104e4.tar.bz2 portage-31c4e5832a8dc79fdba7308459444fd654a104e4.zip |
Fix config.pop() so that is will properly raise a KeyError. (trunk r8704)
svn path=/main/branches/2.1.2/; revision=8705
-rw-r--r-- | pym/portage.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/pym/portage.py b/pym/portage.py index a9fe9fc9f..9e5b1bed5 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2420,11 +2420,18 @@ class config: 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): |