Python 3 fix: direct indexing of bytes returns an int.

This commit is contained in:
Itamar Turner-Trauring 2020-12-23 09:54:35 -05:00
parent 58cb757816
commit 3c8550b666

View File

@ -194,7 +194,7 @@ def flip_one_bit(s, offset=0, size=None):
if size is None:
size=len(s)-offset
i = randrange(offset, offset+size)
result = s[:i] + bchr(ord(s[i])^(0x01<<randrange(0, 8))) + s[i+1:]
result = s[:i] + bchr(ord(s[i:i+1])^(0x01<<randrange(0, 8))) + s[i+1:]
assert result != s, "Internal error -- flip_one_bit() produced the same string as its input: %s == %s" % (result, s)
return result