Check NamedLoaderContext obj is not None, before creating a dictionary

This commit is contained in:
David Murphy 2023-04-11 19:07:38 -06:00 committed by Gareth J. Greenaway
parent 196023a086
commit a1f54d9f27
2 changed files with 4 additions and 2 deletions

1
changelog/62477.fixed.md Normal file
View file

@ -0,0 +1 @@
Issue #62477: Check NamedLoadedContext mapping is not None, before attempting to create a dictory with it

View file

@ -4,7 +4,6 @@ encrypted keys to general payload dynamics and packaging, these happen
in here
"""
import collections.abc
import datetime
import gc
import logging
@ -164,7 +163,9 @@ def dumps(msg, use_bin_type=False):
return tuple(obj)
elif isinstance(obj, CaseInsensitiveDict):
return dict(obj)
elif isinstance(obj, collections.abc.MutableMapping):
elif isinstance(obj, salt.loader.context.NamedLoaderContext):
if obj.value() is None:
return {}
return dict(obj)
# Nothing known exceptions found. Let msgpack raise its own.
return obj