mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Updated check and return if obj.value() if dict else empty dictionary
This commit is contained in:
parent
8c60ddb291
commit
25e9a5c706
3 changed files with 5 additions and 4 deletions
|
@ -1 +1 @@
|
|||
Check NamedLoadedContext mapping is not None, before attempting to create a dictory with it
|
||||
Check NamedLoadedContext mapping is not None, before attempting to create a dictionary with it
|
||||
|
|
|
@ -32,7 +32,7 @@ def loader_context(loader):
|
|||
class NamedLoaderContext(collections.abc.MutableMapping):
|
||||
"""
|
||||
A NamedLoaderContext object is injected by the loader providing access to
|
||||
Salt's 'magic dunders' (__salt__, __utils__, ect).
|
||||
Salt's 'magic dunders' (__salt__, __utils__, etc).
|
||||
"""
|
||||
|
||||
def __init__(self, name, loader_context, default=None):
|
||||
|
|
|
@ -166,9 +166,10 @@ def dumps(msg, use_bin_type=False):
|
|||
elif isinstance(obj, CaseInsensitiveDict):
|
||||
return dict(obj)
|
||||
elif isinstance(obj, NamedLoaderContext):
|
||||
if obj.value() is None:
|
||||
if isinstance(obj.value(), dict):
|
||||
return obj.value()
|
||||
else:
|
||||
return {}
|
||||
return dict(obj)
|
||||
elif isinstance(obj, collections.abc.MutableMapping):
|
||||
return dict(obj)
|
||||
# Nothing known exceptions found. Let msgpack raise its own.
|
||||
|
|
Loading…
Add table
Reference in a new issue