From 1688d19c7d9efd4f7cbce2de645ef9aef2f01869 Mon Sep 17 00:00:00 2001 From: Nitin Madhok Date: Mon, 20 Apr 2015 13:17:02 -0400 Subject: [PATCH 1/3] Fixing issue that causes RuntimeError maximum recursion Fixes #22839 --- salt/utils/lazy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/utils/lazy.py b/salt/utils/lazy.py index ef60013e00..6f35a57b19 100644 --- a/salt/utils/lazy.py +++ b/salt/utils/lazy.py @@ -98,8 +98,8 @@ class LazyDict(collections.MutableMapping): ''' Check if the name is in the dict and return it if it is ''' - if name in self: - return self[name] + if name in self._dict: + return self._dict[name] raise AttributeError(name) def __len__(self): From 5b6f2995ebf32344e8f162c3646edafd9c6e2746 Mon Sep 17 00:00:00 2001 From: Nitin Madhok Date: Mon, 20 Apr 2015 14:55:05 -0400 Subject: [PATCH 2/3] Makes changes as suggested by Thomas so the loader does not break --- salt/utils/lazy.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/salt/utils/lazy.py b/salt/utils/lazy.py index 6f35a57b19..1bb321c8cb 100644 --- a/salt/utils/lazy.py +++ b/salt/utils/lazy.py @@ -98,8 +98,16 @@ class LazyDict(collections.MutableMapping): ''' Check if the name is in the dict and return it if it is ''' - if name in self._dict: - return self._dict[name] + if name not in self._dict and not self.loaded: + # load the item + if self._load(name): + log.debug('LazyLoaded {0}'.format(name)) + return self._dict[name] + else: + log.debug('Could not LazyLoad {0}'.format(key)) + raise KeyError(key) + elif name in self: + return self[name] raise AttributeError(name) def __len__(self): From 1f703ef5480e5559bc7f6e09de8f049ab3ba1288 Mon Sep 17 00:00:00 2001 From: Nitin Madhok Date: Mon, 20 Apr 2015 16:54:42 -0400 Subject: [PATCH 3/3] Rename key --- salt/utils/lazy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/utils/lazy.py b/salt/utils/lazy.py index 1bb321c8cb..4db5a0628f 100644 --- a/salt/utils/lazy.py +++ b/salt/utils/lazy.py @@ -104,8 +104,8 @@ class LazyDict(collections.MutableMapping): log.debug('LazyLoaded {0}'.format(name)) return self._dict[name] else: - log.debug('Could not LazyLoad {0}'.format(key)) - raise KeyError(key) + log.debug('Could not LazyLoad {0}'.format(name)) + raise KeyError(name) elif name in self: return self[name] raise AttributeError(name)