From e05f0440344e0cc6946f65c139a1e447d38774ae Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Fri, 3 Jul 2015 16:35:57 +0200 Subject: [PATCH] Pass on 'compresslevel' for gzip / bzip2 compressed archives only Otherwise we crash when opening plain tar files for writing: TypeError: taropen() takes from 2 to 4 positional arguments but 5 were given First part of the unit test fix. Verified with debug statements in gzopen() that passing on the parameter still works. --- deltatar/tarfile.py | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/deltatar/tarfile.py b/deltatar/tarfile.py index 356b154..729079f 100644 --- a/deltatar/tarfile.py +++ b/deltatar/tarfile.py @@ -1908,7 +1908,12 @@ class TarFile(object): func = getattr(cls, cls.OPEN_METH[comptype]) else: raise CompressionError("unknown compression type %r" % comptype) - return func(name, filemode, fileobj, compresslevel, **kwargs) + + # Pass on compression level for gzip / bzip2. + if comptype == 'gz' or comptype == 'bz2': + kwargs['compresslevel'] = compresslevel + + return func(name, filemode, fileobj, **kwargs) elif "|" in mode: filemode, comptype = mode.split("|", 1) -- 1.7.1