diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-03-11 06:16:14 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-03-11 06:16:14 +0000 |
commit | 1bc7e057f9271445000a5b78dc900ea1669dfbff (patch) | |
tree | 61d5be441cdff58f77b85871cc282005edc9cd0b /pym | |
parent | 9e8ae920e12e4bee12b1ae99823de2c15d80ffc1 (diff) | |
download | portage-1bc7e057f9271445000a5b78dc900ea1669dfbff.tar.gz portage-1bc7e057f9271445000a5b78dc900ea1669dfbff.tar.bz2 portage-1bc7e057f9271445000a5b78dc900ea1669dfbff.zip |
In LazyItemsDict, avoid storing empty lists and dicts when no positional or
keyword arguments are given. (trunk r12700)
svn path=/main/branches/2.1.6/; revision=12955
Diffstat (limited to 'pym')
-rw-r--r-- | pym/portage/util.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pym/portage/util.py b/pym/portage/util.py index a8dbf6c27..2cb14b34d 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -1072,6 +1072,10 @@ class LazyItemsDict(dict): def addLazyItem(self, item_key, value_callable, *pargs, **kwargs): """Add a lazy item for the given key. When the item is requested, value_callable will be called with *pargs and **kwargs arguments.""" + if not pargs: + pargs = None + if not kwargs: + kwargs = None self.lazy_items[item_key] = (value_callable, pargs, kwargs) # make it show up in self.keys(), etc... dict.__setitem__(self, item_key, None) @@ -1094,6 +1098,10 @@ class LazyItemsDict(dict): def __getitem__(self, item_key): if item_key in self.lazy_items: value_callable, pargs, kwargs = self.lazy_items[item_key] + if pargs is None: + pargs = () + if kwargs is None: + kwargs = {} return value_callable(*pargs, **kwargs) else: return dict.__getitem__(self, item_key) |