Update msgpack calls for newer msgpack

This commit is contained in:
twangboy 2019-05-07 16:34:21 -06:00 committed by Pedro Algarvio
parent d47222ce1e
commit 243b5124ef
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -254,11 +254,15 @@ class IPCClient(object):
self.socket_path = socket_path
self._closing = False
self.stream = None
if six.PY2:
encoding = None
# msgpack deprecated `encoding` starting with version 0.5.2
if msgpack.version >= (0, 5, 2):
msgpack_kwargs = {'raw': False}
else:
encoding = 'utf-8'
self.unpacker = msgpack.Unpacker(encoding=encoding)
if six.PY2:
msgpack_kwargs = {'encoding': None}
else:
msgpack_kwargs = {'encoding': 'utf-8'}
self.unpacker = msgpack.Unpacker(**msgpack_kwargs)
def connected(self):
return self.stream is not None and not self.stream.closed()