changeset: 104661:d4fce66ebe01 branch: 3.5 parent: 104653:900c47c98711 user: Serhiy Storchaka date: Sun Oct 23 15:55:09 2016 +0300 files: Lib/shutil.py Lib/test/test_shutil.py Misc/NEWS description: Issue #28488: shutil.make_archive() no longer adds entry "./" to ZIP archive. diff -r 900c47c98711 -r d4fce66ebe01 Lib/shutil.py --- a/Lib/shutil.py Sun Oct 23 13:07:59 2016 +0300 +++ b/Lib/shutil.py Sun Oct 23 15:55:09 2016 +0300 @@ -680,9 +680,10 @@ with zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) as zf: path = os.path.normpath(base_dir) - zf.write(path, path) - if logger is not None: - logger.info("adding '%s'", path) + if path != os.curdir: + zf.write(path, path) + if logger is not None: + logger.info("adding '%s'", path) for dirpath, dirnames, filenames in os.walk(base_dir): for name in sorted(dirnames): path = os.path.normpath(os.path.join(dirpath, name)) diff -r 900c47c98711 -r d4fce66ebe01 Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py Sun Oct 23 13:07:59 2016 +0300 +++ b/Lib/test/test_shutil.py Sun Oct 23 15:55:09 2016 +0300 @@ -1068,6 +1068,19 @@ with support.change_cwd(work_dir): base_name = os.path.abspath(rel_base_name) + res = make_archive(rel_base_name, 'zip', root_dir) + + self.assertEqual(res, base_name + '.zip') + self.assertTrue(os.path.isfile(res)) + self.assertTrue(zipfile.is_zipfile(res)) + with zipfile.ZipFile(res) as zf: + self.assertCountEqual(zf.namelist(), + ['dist/', 'dist/sub/', 'dist/sub2/', + 'dist/file1', 'dist/file2', 'dist/sub/file3', + 'outer']) + + with support.change_cwd(work_dir): + base_name = os.path.abspath(rel_base_name) res = make_archive(rel_base_name, 'zip', root_dir, base_dir) self.assertEqual(res, base_name + '.zip') diff -r 900c47c98711 -r d4fce66ebe01 Misc/NEWS --- a/Misc/NEWS Sun Oct 23 13:07:59 2016 +0300 +++ b/Misc/NEWS Sun Oct 23 15:55:09 2016 +0300 @@ -110,6 +110,8 @@ Library ------- +- Issue #28488: shutil.make_archive() no longer add entry "./" to ZIP archive. + - Issue #24452: Make webbrowser support Chrome on Mac OS X. - Issue #20766: Fix references leaked by pdb in the handling of SIGINT