array.array.tostring is removed in Python 3.9

This commit is contained in:
Odd Stråbø 2021-02-22 04:10:32 +01:00
parent ce111cfb61
commit 153396acbb

View file

@ -36,6 +36,7 @@ except ImportError:
import os import os
import sys
import array import array
import struct import struct
import uuid import uuid
@ -357,7 +358,11 @@ class ABNF(object):
_d = array.array("B", data) _d = array.array("B", data)
for i in range(len(_d)): for i in range(len(_d)):
_d[i] ^= _m[i % 4] _d[i] ^= _m[i % 4]
return _d.tostring()
if sys.version_info >= (3, 2):
return _d.tobytes()
else:
return _d.tostring()
class WebSocket(object): class WebSocket(object):