Commit 2ba3973e authored by Mattias Ellert's avatar Mattias Ellert
Browse files

Compatibility with Python 3.9.

https://bugzilla.redhat.com/show_bug.cgi?id=1793465
https://docs.python.org/3.9/whatsnew/3.9.html#removed

array.array: tostring() and fromstring() methods have been removed.
They were aliases to tobytes() and frombytes(), deprecated since
Python 3.2.
parent ffb55404
......@@ -26,7 +26,10 @@ class BitVector(object):
else:
assert n_bits == len(bits) * TYPE_SIZE, "Size and given bits does not match"
self.bits = array.array(ARRAY_TYPE)
self.bits.fromstring(bits)
try:
self.bits.frombytes(bits)
except AttributeError:
self.bits.fromstring(bits)
def __setitem__(self, index, value):
......@@ -41,4 +44,7 @@ class BitVector(object):
def tostring(self):
return self.bits.tostring()
try:
return self.bits.tobytes()
except AttributeError:
return self.bits.tostring()
......@@ -104,7 +104,10 @@ class BloomFilter(object):
def serialize(self):
return self.bits.tostring()
try:
return self.bits.tobytes()
except AttributeError:
return self.bits.tostring()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment