[Python-checkins] cpython (merge 3.4 -> default): Issue #23421: Fixed compression in tarfile CLI. Patch by wdv4758h.
serhiy.storchaka
python-checkins at python.org
Tue Feb 10 07:48:43 CET 2015
https://hg.python.org/cpython/rev/5b70eb1cfad0
changeset: 94578:5b70eb1cfad0
parent: 94576:76170e33f251
parent: 94577:2a06379f6562
user: Serhiy Storchaka <storchaka at gmail.com>
date: Tue Feb 10 08:47:10 2015 +0200
summary:
Issue #23421: Fixed compression in tarfile CLI. Patch by wdv4758h.
files:
Lib/tarfile.py | 16 ++++++++--------
Lib/test/test_tarfile.py | 15 +++++++++++++++
Misc/NEWS | 3 +++
3 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2494,16 +2494,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 --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -2006,6 +2006,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 --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,12 +13,15 @@
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?
=================================
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list