Use byte literal in a few places as needed.

This commit is contained in:
Neil Schemenauer 2016-04-07 19:39:35 +00:00
parent 8420d45452
commit b70d6a275c
2 changed files with 8 additions and 8 deletions

View File

@ -62,12 +62,12 @@ status_reasons = {
507: 'Insufficient Storage',
}
_GZIP_HEADER = ("\037\213" # magic
"\010" # compression method
"\000" # flags
"\000\000\000\000" # time, who cares?
"\002"
"\377")
_GZIP_HEADER = (b"\037\213" # magic
b"\010" # compression method
b"\000" # flags
b"\000\000\000\000" # time, who cares?
b"\002"
b"\377")
# content that is already compressed, don't bother trying
_GZIP_EXCLUDE = set(["application/pdf",
@ -265,7 +265,7 @@ class HTTPResponse:
def _generate_compressed(self, body):
co = zlib.compressobj(6, zlib.DEFLATED, -zlib.MAX_WBITS,
zlib.DEF_MEM_LEVEL, 0)
crc = zlib.crc32('') & 0xffffffff
crc = zlib.crc32(b'') & 0xffffffff
n = 0
yield _GZIP_HEADER
for chunk in body:

View File

@ -169,7 +169,7 @@ PTL_EXT = ".ptl"
def dump(code, filename, fp):
mtime = os.stat(filename)[stat.ST_MTIME]
fp.write('\0\0\0\0')
fp.write(b'\0\0\0\0')
fp.write(struct.pack('<I', mtime))
marshal.dump(code, fp)
fp.flush()