Convert various string literals to bytes.
This commit is contained in:
parent
c4140a158e
commit
da3f228740
|
@ -38,7 +38,7 @@ class Error(Exception):
|
||||||
# Various constants
|
# Various constants
|
||||||
REASONABLY_LARGE = 32768 # Minimal amount we pass the rle-coder
|
REASONABLY_LARGE = 32768 # Minimal amount we pass the rle-coder
|
||||||
LINELEN = 64
|
LINELEN = 64
|
||||||
RUNCHAR = chr(0x90) # run-length introducer
|
RUNCHAR = b"\x90"
|
||||||
|
|
||||||
#
|
#
|
||||||
# This code is no longer byte-order dependent
|
# This code is no longer byte-order dependent
|
||||||
|
@ -351,11 +351,11 @@ class _Rledecoderengine:
|
||||||
# otherwise: keep 1 byte.
|
# otherwise: keep 1 byte.
|
||||||
#
|
#
|
||||||
mark = len(self.pre_buffer)
|
mark = len(self.pre_buffer)
|
||||||
if self.pre_buffer[-3:] == RUNCHAR + '\0' + RUNCHAR:
|
if self.pre_buffer[-3:] == RUNCHAR + b'\0' + RUNCHAR:
|
||||||
mark = mark - 3
|
mark = mark - 3
|
||||||
elif self.pre_buffer[-1] == RUNCHAR:
|
elif self.pre_buffer[-1] == RUNCHAR:
|
||||||
mark = mark - 2
|
mark = mark - 2
|
||||||
elif self.pre_buffer[-2:] == RUNCHAR + '\0':
|
elif self.pre_buffer[-2:] == RUNCHAR + b'\0':
|
||||||
mark = mark - 2
|
mark = mark - 2
|
||||||
elif self.pre_buffer[-2] == RUNCHAR:
|
elif self.pre_buffer[-2] == RUNCHAR:
|
||||||
pass # Decode all
|
pass # Decode all
|
||||||
|
|
|
@ -31,13 +31,13 @@ class NoEOFStringIO(io.BytesIO):
|
||||||
"""
|
"""
|
||||||
def read(self, n=-1):
|
def read(self, n=-1):
|
||||||
data = io.BytesIO.read(self, n)
|
data = io.BytesIO.read(self, n)
|
||||||
if data == '':
|
if data == b'':
|
||||||
raise AssertionError('caller tried to read past EOF')
|
raise AssertionError('caller tried to read past EOF')
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def readline(self, length=None):
|
def readline(self, length=None):
|
||||||
data = io.BytesIO.readline(self, length)
|
data = io.BytesIO.readline(self, length)
|
||||||
if data == '':
|
if data == b'':
|
||||||
raise AssertionError('caller tried to read past EOF')
|
raise AssertionError('caller tried to read past EOF')
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ _array_fmts = None, 'b', 'h', None, 'l'
|
||||||
|
|
||||||
# Determine endian-ness
|
# Determine endian-ness
|
||||||
import struct
|
import struct
|
||||||
if struct.pack("h", 1) == "\000\001":
|
if struct.pack("h", 1) == b"\000\001":
|
||||||
big_endian = 1
|
big_endian = 1
|
||||||
else:
|
else:
|
||||||
big_endian = 0
|
big_endian = 0
|
||||||
|
|
Loading…
Reference in New Issue