Merge pull request #26871 from rallytime/bp-26852

Back-port #26852 to 2015.5
This commit is contained in:
Justin Findlay 2015-09-07 21:43:07 -06:00
commit de9350466e

View file

@ -26,6 +26,7 @@ except ImportError:
log = logging.getLogger(__name__)
HAS_MSGPACK = False
try:
# Attempt to import msgpack
import msgpack
@ -33,10 +34,12 @@ try:
# for some msgpack bindings, check for it
if msgpack.loads(msgpack.dumps([1, 2, 3]), use_list=True) is None:
raise ImportError
HAS_MSGPACK = True
except ImportError:
# Fall back to msgpack_pure
try:
import msgpack_pure as msgpack
import msgpack_pure as msgpack # pylint: disable=import-error
HAS_MSGPACK = True
except ImportError:
# TODO: Come up with a sane way to get a configured logfile
# and write to the logfile when this error is hit also
@ -48,7 +51,7 @@ except ImportError:
#sys.exit(salt.defaults.exitcodes.EX_GENERIC)
if not hasattr(msgpack, 'exceptions'):
if HAS_MSGPACK and not hasattr(msgpack, 'exceptions'):
class PackValueError(Exception):
'''
older versions of msgpack do not have PackValueError