Skip to content

Commit b59ebc7

Browse files
committed
try fix
error: unpack requires a string argument of length 4
1 parent facd62c commit b59ebc7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pymysqlreplication/bitmap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ def _createLastWordMask(self):
6868
b = bytearray(struct.pack("<I", self._lastWordMask))
6969
b[3] = mask
7070

71-
self._lastWordMask = struct.unpack("<I", b)[0]
71+
self._lastWordMask = struct.unpack("<I", bytes(b))[0]
7272

7373
def bits_set(self):
7474
res = 0
7575
for i in range(0, int(len(self._bitmap) / 4) - 1):
76-
res += self._countBitsUint32(struct.unpack("<I", self._bitmap[i*4:i*4 + 4])[0])
76+
res += self._countBitsUint32(struct.unpack("<I", bytes(self._bitmap[i*4:i*4 + 4]))[0])
7777

78-
res += self._countBitsUint32(struct.unpack("<I", self._bitmap[-4:])[0] & ~self._lastWordMask)
78+
res += self._countBitsUint32(struct.unpack("<I", bytes(self._bitmap[-4:]))[0] & ~self._lastWordMask)
7979

8080
return res
8181

0 commit comments

Comments
 (0)