Skip to content

Commit

Permalink
Issue #23421: Fixed compression in tarfile CLI. Patch by wdv4758h.
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Feb 10, 2015
2 parents f215abc + 6c71b45 commit 1d3ec8b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2494,16 +2494,16 @@ def main():
_, 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
Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,21 @@ def test_create_command_dot_started_filename(self):
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':
Expand Down
3 changes: 3 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ Core and Builtins
Library
-------

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

- Issue #23361: Fix possible overflow in Windows subprocess creation code.

- logging.handlers.QueueListener now takes a respect_handler_level keyword
argument which, if set to True, will pass messages to handlers taking handler
levels into account.


What's New in Python 3.5 alpha 1?
=================================

Expand Down

0 comments on commit 1d3ec8b

Please sign in to comment.