Make sure files are read in binary mode.
This commit is contained in:
parent
70fb808dae
commit
34e6a62c6a
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue