Make sure files are read in binary mode.

This commit is contained in:
Bastian Kleineidam 2013-02-23 13:48:47 +01:00
parent 70fb808dae
commit 34e6a62c6a
3 changed files with 3 additions and 3 deletions

View File

@ -54,7 +54,7 @@ def create_bzip2 (archive, compression, cmd, *args, **kwargs):
bz2file = bz2.BZ2File(archive, 'wb') bz2file = bz2.BZ2File(archive, 'wb')
try: try:
filename = args[0] filename = args[0]
with open(filename) as srcfile: with open(filename, 'rb') as srcfile:
data = srcfile.read(READ_SIZE_BYTES) data = srcfile.read(READ_SIZE_BYTES)
while data: while data:
bz2file.write(data) bz2file.write(data)

View File

@ -52,7 +52,7 @@ def create_gzip (archive, compression, cmd, *args, **kwargs):
gzipfile = gzip.GzipFile(archive, 'wb') gzipfile = gzip.GzipFile(archive, 'wb')
try: try:
filename = args[0] filename = args[0]
with open(filename) as srcfile: with open(filename, 'rb') as srcfile:
data = srcfile.read(READ_SIZE_BYTES) data = srcfile.read(READ_SIZE_BYTES)
while data: while data:
gzipfile.write(data) gzipfile.write(data)

View File

@ -58,7 +58,7 @@ def _create(archive, compression, cmd, format, *args, **kwargs):
lzmafile = lzma.LZMAFile(archive, 'wb', format) lzmafile = lzma.LZMAFile(archive, 'wb', format)
try: try:
filename = args[0] filename = args[0]
with open(filename) as srcfile: with open(filename, 'rb') as srcfile:
data = srcfile.read(READ_SIZE_BYTES) data = srcfile.read(READ_SIZE_BYTES)
while data: while data:
lzmafile.write(data) lzmafile.write(data)