Merge pull request #53242 from s0undt3ch/hotfix/msgpack-ipc-2019.2.1

[2019.2.1] newer msgpack ipc fixes
This commit is contained in:
Shane Lee 2019-06-03 17:39:08 -06:00 committed by GitHub
commit ce5d79adce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -164,11 +164,16 @@ class IPCServer(object):
return return_message
else:
return _null
if six.PY2:
encoding = None
# msgpack deprecated `encoding` starting with version 0.5.2
if msgpack.version >= (0, 5, 2):
# Under Py2 we still want raw to be set to True
msgpack_kwargs = {'raw': six.PY2}
else:
encoding = 'utf-8'
unpacker = msgpack.Unpacker(encoding=encoding)
if six.PY2:
msgpack_kwargs = {'encoding': None}
else:
msgpack_kwargs = {'encoding': 'utf-8'}
unpacker = msgpack.Unpacker(**msgpack_kwargs)
while not stream.closed():
try:
wire_bytes = yield stream.read_bytes(4096, partial=True)
@ -254,11 +259,16 @@ 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):
# Under Py2 we still want raw to be set to True
msgpack_kwargs = {'raw': six.PY2}
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()