[Python-checkins] cpython (merge 3.4 -> default): Issue #21280: Fixed a bug in shutil.make_archive() when create an archive of
serhiy.storchaka
python-checkins at python.org
Thu Nov 27 23:53:11 CET 2014
https://hg.python.org/cpython/rev/c605dcf9786f
changeset: 93634:c605dcf9786f
parent: 93632:c8adee8a0ccb
parent: 93633:8fa9097eadcb
user: Serhiy Storchaka <storchaka at gmail.com>
date: Fri Nov 28 00:49:50 2014 +0200
summary:
Issue #21280: Fixed a bug in shutil.make_archive() when create an archive of
current directory in current directory.
files:
Lib/shutil.py | 4 ++--
Lib/test/test_shutil.py | 15 +++++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/Lib/shutil.py b/Lib/shutil.py
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -617,7 +617,7 @@
archive_name = base_name + '.tar' + compress_ext.get(compress, '')
archive_dir = os.path.dirname(archive_name)
- if not os.path.exists(archive_dir):
+ if archive_dir and not os.path.exists(archive_dir):
if logger is not None:
logger.info("creating %s", archive_dir)
if not dry_run:
@@ -662,7 +662,7 @@
zip_filename = base_name + ".zip"
archive_dir = os.path.dirname(base_name)
- if not os.path.exists(archive_dir):
+ if archive_dir and not os.path.exists(archive_dir):
if logger is not None:
logger.info("creating %s", archive_dir)
if not dry_run:
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -1132,6 +1132,21 @@
finally:
unregister_archive_format('xxx')
+ def test_make_tarfile_in_curdir(self):
+ # Issue #21280
+ root_dir = self.mkdtemp()
+ with support.change_cwd(root_dir):
+ self.assertEqual(make_archive('test', 'tar'), 'test.tar')
+ self.assertTrue(os.path.isfile('test.tar'))
+
+ @requires_zlib
+ def test_make_zipfile_in_curdir(self):
+ # Issue #21280
+ root_dir = self.mkdtemp()
+ with support.change_cwd(root_dir):
+ self.assertEqual(make_archive('test', 'zip'), 'test.zip')
+ self.assertTrue(os.path.isfile('test.zip'))
+
def test_register_archive_format(self):
self.assertRaises(TypeError, register_archive_format, 'xxx', 1)
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list