From 4e1c248d9b02b1ef04ac5207af2625130d45c45c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 3 Jul 2009 20:29:39 +0000 Subject: [PATCH] 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 --- pym/portage/util.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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] -- 2.26.2