From c89a03d6dc0e311c0648ab4960180fb145762c9e Mon Sep 17 00:00:00 2001 From: Ilya Kulakov Date: Wed, 31 Oct 2018 21:25:38 -0700 Subject: [PATCH] Do not pass compresslevel unless set by user. Compression lib may not recognize None as a valid value. --- git_archive_all.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/git_archive_all.py b/git_archive_all.py index 9b3e957..ea9e8c2 100755 --- a/git_archive_all.py +++ b/git_archive_all.py @@ -150,7 +150,10 @@ def create(self, output_path, dry_run=False, output_format=None, compresslevel=N from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED if sys.version_info > (3, 7): - archive = ZipFile(path.abspath(output_path), 'w', compresslevel=compresslevel) + if compresslevel is not None: + archive = ZipFile(path.abspath(output_path), 'w', compresslevel=compresslevel) + else: + archive = ZipFile(path.abspath(output_path), 'w') else: if compresslevel is not None: raise ValueError("Compression level for zip archives requires Python 3.7+") @@ -171,7 +174,10 @@ def add_file(file_path, arcname): mode = self.TARFILE_FORMATS[output_format] try: - archive = tarfile.open(path.abspath(output_path), mode, compresslevel=compresslevel) + if compresslevel is not None: + archive = tarfile.open(path.abspath(output_path), mode, compresslevel=compresslevel) + else: + archive = tarfile.open(path.abspath(output_path), mode) except TypeError: if compresslevel is not None: raise ValueError("{0} cannot be compressed".format(output_format))