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.

Created on 2018-01-28 15:22 by bbayles, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5397 closed bbayles, 2018-01-28 21:49
PR 21470 merged ZackerySpytz, 2020-07-14 05:49
PR 27674 merged miss-islington, 2021-08-09 10:05
PR 27675 merged miss-islington, 2021-08-09 10:06
Messages (5)
msg310954 - (view) Author: bbayles (bbayles) * Date: 2018-01-28 15:22
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
msg311582 - (view) Author: bbayles (bbayles) * Date: 2018-02-04 02:12
In working on a patch I convinced myself that a better change might just be to document that you can use the *preset* keyword for LZMA compression instead of *compresslevel*.
msg399254 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-09 10:05
 New changeset eb2d4a66ff07aa6e51cfaaa31afed31addf76936 by Zackery Spytz in branch 'main': bpo-32695: Docs and tests for compresslevel and preset kwargs in tarfile (GH-21470) https://github.com/python/cpython/commit/eb2d4a66ff07aa6e51cfaaa31afed31addf76936 
msg399256 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-09 10:30
 New changeset ede221e51796f3f5471278aabd9105870f79dfb5 by Miss Islington (bot) in branch '3.9': bpo-32695: Docs and tests for compresslevel and preset kwargs in tarfile (GH-21470) (GH-27674) https://github.com/python/cpython/commit/ede221e51796f3f5471278aabd9105870f79dfb5 
msg399257 - (view) Author: miss-islington (miss-islington) Date: 2021-08-09 10:30
 New changeset d5c8ad24716d146ffa025e09dad85e5a1bac5c77 by Miss Islington (bot) in branch '3.10': bpo-32695: Docs and tests for compresslevel and preset kwargs in tarfile (GH-21470) https://github.com/python/cpython/commit/d5c8ad24716d146ffa025e09dad85e5a1bac5c77 
History
Date User Action Args
2022-04-11 14:58:57adminsetgithub: 76876
2021-08-09 10:39:27lukasz.langasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.6, Python 3.7
2021-08-09 10:30:34miss-islingtonsetmessages: + msg399257
2021-08-09 10:30:26lukasz.langasetmessages: + msg399256
2021-08-09 10:06:09miss-islingtonsetpull_requests: + pull_request26163
2021-08-09 10:05:43miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26162
2021-08-09 10:05:34lukasz.langasetnosy: + lukasz.langa
messages: + msg399254
2020-07-14 05:49:48ZackerySpytzsetnosy: + ZackerySpytz
pull_requests: + pull_request20614
2018-02-04 02:12:13bbaylessetmessages: + msg311582
2018-01-28 21:49:41bbaylessetkeywords: + patch
stage: patch review
pull_requests: + pull_request5232
2018-01-28 15:22:05bbaylescreate