This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bbayles
Recipients bbayles
Date 2018-01-28.15:22:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1517152925.99.0.467229070634.issue32695@psf.upfronthosting.co.za>
In-reply-to
Content
tarfile.open() allows for specifying both a compression type and a compression level. However, the compresslevel parameter doesn't work when using the xz modes.

    import tarfile
    good_archive = tarfile.open('/tmp/dummy.tar.gz', 'w:gz', compresslevel=9)
    bad_archive = tarfile.open('/tmp/dummy.tar.gz', 'w:xz', compresslevel=9)

This gives an error in the tarfile.TarFile constructor:

    TypeError: __init__() got an unexpected keyword argument 'compresslevel'

This appears to be due to tarfile.xzopen() specifying a preset keyword instead of a compresslevel keyword. This matches the LZMAFile compressor, but it means that it doesn't get passed in and is then carried along in the kwargs - see [1].

Changing to lzma.LZMAFile(fileobj or name, mode, preset=compresslevel) seems to fix the issue. Assuming that's the right fix, I'll submit a PR.

[1] https://github.com/python/cpython/blob/374c6e178a7599aae46c857b17c6c8bc19dfe4c2/Lib/tarfile.py#L1684-L1699
History
Date User Action Args
2018-01-28 15:22:06bbaylessetrecipients: + bbayles
2018-01-28 15:22:05bbaylessetmessageid: <1517152925.99.0.467229070634.issue32695@psf.upfronthosting.co.za>
2018-01-28 15:22:05bbayleslinkissue32695 messages
2018-01-28 15:22:05bbaylescreate