New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tarfile.open() raises TypeError when using compresslevel parameter with LZMA #76876
Comments
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:
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] Lines 1684 to 1699 in 374c6e1
|
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*. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: