From: Thomas Jarosch Date: Fri, 3 Jul 2015 14:35:57 +0000 (+0200) Subject: Pass on 'compresslevel' for gzip / bzip2 compressed archives only X-Git-Tag: v2.2~45 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=e05f0440344e0cc6946f65c139a1e447d38774ae;p=python-delta-tar 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. --- 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)