Fix config.pop() so that is will properly raise a KeyError. (trunk r8704)
authorZac Medico <zmedico@gentoo.org>
Tue, 27 Nov 2007 02:08:53 +0000 (02:08 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 27 Nov 2007 02:08:53 +0000 (02:08 -0000)
svn path=/main/branches/2.1.2/; revision=8705

pym/portage.py

index a9fe9fc9fea0e5a4657bd9205f785c13fa73517c..9e5b1bed54aa7e1a80095496445b9b1210013022 100644 (file)
@@ -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):