cpython: 2a06379f6562 (original) (raw)
Mercurial > cpython
changeset 94577:2a06379f6562 3.4
Issue #23421: Fixed compression in tarfile CLI. Patch by wdv4758h. [#23421]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Tue, 10 Feb 2015 08:45:53 +0200 |
parents | b82cc9180a78 |
children | 5b70eb1cfad0 645f3d750be1 |
files | Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS |
diffstat | 3 files changed, 26 insertions(+), 8 deletions(-)[+] [-] Lib/tarfile.py 16 Lib/test/test_tarfile.py 15 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -2491,16 +2491,16 @@ def main(): _, ext = os.path.splitext(tar_name) compressions = { # gz
'gz': 'gz',[](#l1.7)
'tgz': 'gz',[](#l1.8)
'.gz': 'gz',[](#l1.9)
'.tgz': 'gz',[](#l1.10) # xz[](#l1.11)
'xz': 'xz',[](#l1.12)
'txz': 'xz',[](#l1.13)
'.xz': 'xz',[](#l1.14)
'.txz': 'xz',[](#l1.15) # bz2[](#l1.16)
'bz2': 'bz2',[](#l1.17)
'tbz': 'bz2',[](#l1.18)
'tbz2': 'bz2',[](#l1.19)
'tb2': 'bz2',[](#l1.20)
'.bz2': 'bz2',[](#l1.21)
'.tbz': 'bz2',[](#l1.22)
'.tbz2': 'bz2',[](#l1.23)
'.tb2': 'bz2',[](#l1.24) }[](#l1.25) tar_mode = 'w:' + compressions[ext] if ext in compressions else 'w'[](#l1.26) tar_files = args.create[](#l1.27)
--- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -1994,6 +1994,21 @@ class CommandLineTest(unittest.TestCase) finally: support.unlink(tar_name)
- def test_create_command_compressed(self):
files = [support.findfile('tokenize_tests.txt'),[](#l2.8)
support.findfile('tokenize_tests-no-coding-cookie-'[](#l2.9)
'and-utf8-bom-sig-only.txt')][](#l2.10)
for filetype in (GzipTest, Bz2Test, LzmaTest):[](#l2.11)
if not filetype.open:[](#l2.12)
continue[](#l2.13)
try:[](#l2.14)
tar_name = tmpname + '.' + filetype.suffix[](#l2.15)
out = self.tarfilecmd('-c', tar_name, *files)[](#l2.16)
with filetype.taropen(tar_name) as tar:[](#l2.17)
tar.getmembers()[](#l2.18)
finally:[](#l2.19)
support.unlink(tar_name)[](#l2.20)
+ def test_extract_command(self): self.make_simple_tarfile(tmpname) for opt in '-e', '--extract':
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -13,8 +13,11 @@ Core and Builtins Library ------- +- Issue #23421: Fixed compression in tarfile CLI. Patch by wdv4758h. +