diff --git a/salt/payload.py b/salt/payload.py index b3aa28ca9dd..9fdf7b7f448 100644 --- a/salt/payload.py +++ b/salt/payload.py @@ -140,18 +140,26 @@ class Serial(object): return data gc.disable() # performance optimization for msgpack + loads_kwargs = {'use_list': True, + 'ext_hook': ext_type_decoder} if msgpack.version >= (0, 4, 0): # msgpack only supports 'encoding' starting in 0.4.0. # Due to this, if we don't need it, don't pass it at all so # that under Python 2 we can still work with older versions # of msgpack. + if msgpack_version >= (0, 5, 2): + loads_kwargs['raw'] = False + else: + loads_kwargs['encoding'] = encoding try: - ret = msgpack.loads(msg, use_list=True, ext_hook=ext_type_decoder, encoding=encoding) + ret = msgpack.loads(msg, **loads_kwargs) except UnicodeDecodeError: # msg contains binary data - ret = msgpack.loads(msg, use_list=True, ext_hook=ext_type_decoder) + loads_kwargs.pop('raw', None) + loads_kwargs.pop('encoding', None) + ret = msgpack.loads(msg, **loads_kwargs) else: - ret = msgpack.loads(msg, use_list=True, ext_hook=ext_type_decoder) + ret = msgpack.loads(msg, **loads_kwargs) if six.PY3 and encoding is None and not raw: ret = salt.transport.frame.decode_embedded_strs(ret) except Exception as exc: