Commit 832dd5f0 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #23421: Fixed compression in tarfile CLI. Patch by wdv4758h.

parent 22ef9f72
...@@ -2491,16 +2491,16 @@ def main(): ...@@ -2491,16 +2491,16 @@ def main():
_, ext = os.path.splitext(tar_name) _, ext = os.path.splitext(tar_name)
compressions = { compressions = {
# gz # gz
'gz': 'gz', '.gz': 'gz',
'tgz': 'gz', '.tgz': 'gz',
# xz # xz
'xz': 'xz', '.xz': 'xz',
'txz': 'xz', '.txz': 'xz',
# bz2 # bz2
'bz2': 'bz2', '.bz2': 'bz2',
'tbz': 'bz2', '.tbz': 'bz2',
'tbz2': 'bz2', '.tbz2': 'bz2',
'tb2': 'bz2', '.tb2': 'bz2',
} }
tar_mode = 'w:' + compressions[ext] if ext in compressions else 'w' tar_mode = 'w:' + compressions[ext] if ext in compressions else 'w'
tar_files = args.create tar_files = args.create
......
...@@ -1994,6 +1994,21 @@ class CommandLineTest(unittest.TestCase): ...@@ -1994,6 +1994,21 @@ class CommandLineTest(unittest.TestCase):
finally: finally:
support.unlink(tar_name) support.unlink(tar_name)
def test_create_command_compressed(self):
files = [support.findfile('tokenize_tests.txt'),
support.findfile('tokenize_tests-no-coding-cookie-'
'and-utf8-bom-sig-only.txt')]
for filetype in (GzipTest, Bz2Test, LzmaTest):
if not filetype.open:
continue
try:
tar_name = tmpname + '.' + filetype.suffix
out = self.tarfilecmd('-c', tar_name, *files)
with filetype.taropen(tar_name) as tar:
tar.getmembers()
finally:
support.unlink(tar_name)
def test_extract_command(self): def test_extract_command(self):
self.make_simple_tarfile(tmpname) self.make_simple_tarfile(tmpname)
for opt in '-e', '--extract': for opt in '-e', '--extract':
......
...@@ -13,8 +13,11 @@ Core and Builtins ...@@ -13,8 +13,11 @@ Core and Builtins
Library Library
------- -------
- Issue #23421: Fixed compression in tarfile CLI. Patch by wdv4758h.
- Issue #23361: Fix possible overflow in Windows subprocess creation code. - Issue #23361: Fix possible overflow in Windows subprocess creation code.
What's New in Python 3.4.3rc1? What's New in Python 3.4.3rc1?
============================== ==============================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment