py3: fix py_compress_doc

This commit is contained in:
Kovid Goyal 2019-06-22 04:57:50 +05:30
parent abd9e6bcf7
commit abee667506
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -48,11 +48,11 @@ def py_compress_doc(data):
out.write(pack('>H', code)) out.write(pack('>H', code))
i += n i += n
continue continue
ch = data[i] ch = data[i:i+1]
och = ord(ch) och = ord(ch)
i += 1 i += 1
if ch == b' ' and (i + 1) < ldata: if ch == b' ' and (i + 1) < ldata:
onch = ord(data[i]) onch = ord(data[i:i+1])
if onch >= 0x40 and onch < 0x80: if onch >= 0x40 and onch < 0x80:
out.write(pack('>B', onch ^ 0x80)) out.write(pack('>B', onch ^ 0x80))
i += 1 i += 1
@ -63,7 +63,7 @@ def py_compress_doc(data):
j = i j = i
binseq = [ch] binseq = [ch]
while j < ldata and len(binseq) < 8: while j < ldata and len(binseq) < 8:
ch = data[j] ch = data[j:j+1]
och = ord(ch) och = ord(ch)
if och == 0 or (och > 8 and och < 0x80): if och == 0 or (och > 8 and och < 0x80):
break break