From 33710b397230e239a202c650ceaa8148a1a45c01 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 14 Dec 2020 16:08:16 +0100 Subject: [PATCH] Use frombytes() instead of fromstring() Both the Python library and NumPy have changed the names of these functions to better match the new bytes data type it actually uses. --- websockify/websocket.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/websockify/websocket.py b/websockify/websocket.py index d1857f3..f0db3ba 100644 --- a/websockify/websocket.py +++ b/websockify/websocket.py @@ -749,7 +749,7 @@ class WebSocket(object): mask = numpy.frombuffer(mask, dtype, count=1) data = numpy.frombuffer(buf, dtype, count=int(plen / 4)) #b = numpy.bitwise_xor(data, mask).data - b = numpy.bitwise_xor(data, mask).tostring() + b = numpy.bitwise_xor(data, mask).tobytes() if plen % 4: dtype=numpy.dtype('B') @@ -758,15 +758,15 @@ class WebSocket(object): mask = numpy.frombuffer(mask, dtype, count=(plen % 4)) data = numpy.frombuffer(buf, dtype, offset=plen - (plen % 4), count=(plen % 4)) - c = numpy.bitwise_xor(data, mask).tostring() + c = numpy.bitwise_xor(data, mask).tobytes() return b + c else: # Slower fallback data = array.array('B') - data.fromstring(buf) + data.frombytes(buf) for i in range(len(data)): data[i] ^= mask[i % 4] - return data.tostring() + return data.tobytes() def _encode_hybi(self, opcode, buf, mask_key=None, fin=True): """ Encode a HyBi style WebSocket frame.