From 34e6a62c6a9c4940b7c2b27d62b2c25c6c760747 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Sat, 23 Feb 2013 13:48:47 +0100 Subject: [PATCH] Make sure files are read in binary mode. --- patoolib/programs/py_bz2.py | 2 +- patoolib/programs/py_gzip.py | 2 +- patoolib/programs/py_lzma.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patoolib/programs/py_bz2.py b/patoolib/programs/py_bz2.py index 2be3669..71be192 100644 --- a/patoolib/programs/py_bz2.py +++ b/patoolib/programs/py_bz2.py @@ -54,7 +54,7 @@ def create_bzip2 (archive, compression, cmd, *args, **kwargs): bz2file = bz2.BZ2File(archive, 'wb') try: filename = args[0] - with open(filename) as srcfile: + with open(filename, 'rb') as srcfile: data = srcfile.read(READ_SIZE_BYTES) while data: bz2file.write(data) diff --git a/patoolib/programs/py_gzip.py b/patoolib/programs/py_gzip.py index 12c040e..7e7a4c4 100644 --- a/patoolib/programs/py_gzip.py +++ b/patoolib/programs/py_gzip.py @@ -52,7 +52,7 @@ def create_gzip (archive, compression, cmd, *args, **kwargs): gzipfile = gzip.GzipFile(archive, 'wb') try: filename = args[0] - with open(filename) as srcfile: + with open(filename, 'rb') as srcfile: data = srcfile.read(READ_SIZE_BYTES) while data: gzipfile.write(data) diff --git a/patoolib/programs/py_lzma.py b/patoolib/programs/py_lzma.py index d02a146..c80e1c3 100644 --- a/patoolib/programs/py_lzma.py +++ b/patoolib/programs/py_lzma.py @@ -58,7 +58,7 @@ def _create(archive, compression, cmd, format, *args, **kwargs): lzmafile = lzma.LZMAFile(archive, 'wb', format) try: filename = args[0] - with open(filename) as srcfile: + with open(filename, 'rb') as srcfile: data = srcfile.read(READ_SIZE_BYTES) while data: lzmafile.write(data)