cpython: 72da53d3074b (original) (raw)
Mercurial > cpython
changeset 104663:72da53d3074b
Issue #28488: shutil.make_archive() no longer adds entry "./" to ZIP archive. [#28488]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Sun, 23 Oct 2016 15:58:10 +0300 |
parents | 94d34354bef1(current diff)e93149fee04d(diff) |
children | 3e7da46aead3 |
files | Misc/NEWS |
diffstat | 3 files changed, 19 insertions(+), 3 deletions(-)[+] [-] Lib/shutil.py 7 Lib/test/test_shutil.py 13 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -680,9 +680,10 @@ def _make_zipfile(base_name, base_dir, v with zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) as zf: path = os.path.normpath(base_dir)
zf.write(path, path)[](#l1.7)
if logger is not None:[](#l1.8)
logger.info("adding '%s'", path)[](#l1.9)
if path != os.curdir:[](#l1.10)
zf.write(path, path)[](#l1.11)
if logger is not None:[](#l1.12)
logger.info("adding '%s'", path)[](#l1.13) for dirpath, dirnames, filenames in os.walk(base_dir):[](#l1.14) for name in sorted(dirnames):[](#l1.15) path = os.path.normpath(os.path.join(dirpath, name))[](#l1.16)
--- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1066,6 +1066,19 @@ class TestShutil(unittest.TestCase): with support.change_cwd(work_dir): base_name = os.path.abspath(rel_base_name)
res = make_archive(rel_base_name, 'zip', root_dir)[](#l2.7)
self.assertEqual(res, base_name + '.zip')[](#l2.9)
self.assertTrue(os.path.isfile(res))[](#l2.10)
self.assertTrue(zipfile.is_zipfile(res))[](#l2.11)
with zipfile.ZipFile(res) as zf:[](#l2.12)
self.assertCountEqual(zf.namelist(),[](#l2.13)
['dist/', 'dist/sub/', 'dist/sub2/',[](#l2.14)
'dist/file1', 'dist/file2', 'dist/sub/file3',[](#l2.15)
'outer'])[](#l2.16)
with support.change_cwd(work_dir):[](#l2.18)
base_name = os.path.abspath(rel_base_name)[](#l2.19) res = make_archive(rel_base_name, 'zip', root_dir, base_dir)[](#l2.20)
self.assertEqual(res, base_name + '.zip')
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -16,6 +16,8 @@ Core and Builtins
- Issue #23782: Fixed possible memory leak in _PyTraceback_Add() and exception loss in PyTraceBack_Here(). +- Issue #28488: shutil.make_archive() no longer adds entry "./" to ZIP archive. +
- Issue #25953: re.sub() now raises an error for invalid numerical group reference in replacement template even if the pattern is not found in the string. Error message for invalid group reference now includes the