(original) (raw)
changeset: 94577:2a06379f6562 branch: 3.4 parent: 94575:b82cc9180a78 user: Serhiy Storchaka storchaka@gmail.com date: Tue Feb 10 08:45:53 2015 +0200 files: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS description: Issue #23421: Fixed compression in tarfile CLI. Patch by wdv4758h. diff -r b82cc9180a78 -r 2a06379f6562 Lib/tarfile.py --- a/Lib/tarfile.py Mon Feb 09 20:58:52 2015 -0500 +++ b/Lib/tarfile.py Tue Feb 10 08:45:53 2015 +0200 @@ -2491,16 +2491,16 @@ _, ext = os.path.splitext(tar_name) compressions = { # gz - 'gz': 'gz', - 'tgz': 'gz', + '.gz': 'gz', + '.tgz': 'gz', # xz - 'xz': 'xz', - 'txz': 'xz', + '.xz': 'xz', + '.txz': 'xz', # bz2 - 'bz2': 'bz2', - 'tbz': 'bz2', - 'tbz2': 'bz2', - 'tb2': 'bz2', + '.bz2': 'bz2', + '.tbz': 'bz2', + '.tbz2': 'bz2', + '.tb2': 'bz2', } tar_mode = 'w:' + compressions[ext] if ext in compressions else 'w' tar_files = args.create diff -r b82cc9180a78 -r 2a06379f6562 Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py Mon Feb 09 20:58:52 2015 -0500 +++ b/Lib/test/test_tarfile.py Tue Feb 10 08:45:53 2015 +0200 @@ -1994,6 +1994,21 @@ finally: 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): self.make_simple_tarfile(tmpname) for opt in '-e', '--extract': diff -r b82cc9180a78 -r 2a06379f6562 Misc/NEWS --- a/Misc/NEWS Mon Feb 09 20:58:52 2015 -0500 +++ b/Misc/NEWS Tue Feb 10 08:45:53 2015 +0200 @@ -13,8 +13,11 @@ Library ------- +- Issue #23421: Fixed compression in tarfile CLI. Patch by wdv4758h. + - Issue #23361: Fix possible overflow in Windows subprocess creation code. + What's New in Python 3.4.3rc1? ============================== /storchaka@gmail.com