Message310954
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 |
|
Date |
User |
Action |
Args |
2018-01-28 15:22:06 | bbayles | set | recipients:
+ bbayles |
2018-01-28 15:22:05 | bbayles | set | messageid: <1517152925.99.0.467229070634.issue32695@psf.upfronthosting.co.za> |
2018-01-28 15:22:05 | bbayles | link | issue32695 messages |
2018-01-28 15:22:05 | bbayles | create | |
|