mirror of
https://github.com/python/cpython.git
synced 2025-11-28 06:06:26 +00:00
Issue #28488: shutil.make_archive() no longer adds entry "./" to ZIP archive.
This commit is contained in:
parent
61c4c44b2a
commit
666de77727
3 changed files with 19 additions and 3 deletions
|
|
@ -680,6 +680,7 @@ def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None):
|
||||||
with zipfile.ZipFile(zip_filename, "w",
|
with zipfile.ZipFile(zip_filename, "w",
|
||||||
compression=zipfile.ZIP_DEFLATED) as zf:
|
compression=zipfile.ZIP_DEFLATED) as zf:
|
||||||
path = os.path.normpath(base_dir)
|
path = os.path.normpath(base_dir)
|
||||||
|
if path != os.curdir:
|
||||||
zf.write(path, path)
|
zf.write(path, path)
|
||||||
if logger is not None:
|
if logger is not None:
|
||||||
logger.info("adding '%s'", path)
|
logger.info("adding '%s'", path)
|
||||||
|
|
|
||||||
|
|
@ -1066,6 +1066,19 @@ class TestShutil(unittest.TestCase):
|
||||||
work_dir = os.path.dirname(tmpdir2)
|
work_dir = os.path.dirname(tmpdir2)
|
||||||
rel_base_name = os.path.join(os.path.basename(tmpdir2), 'archive')
|
rel_base_name = os.path.join(os.path.basename(tmpdir2), 'archive')
|
||||||
|
|
||||||
|
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):
|
with support.change_cwd(work_dir):
|
||||||
base_name = os.path.abspath(rel_base_name)
|
base_name = os.path.abspath(rel_base_name)
|
||||||
res = make_archive(rel_base_name, 'zip', root_dir, base_dir)
|
res = make_archive(rel_base_name, 'zip', root_dir, base_dir)
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #28488: shutil.make_archive() no longer add entry "./" to ZIP archive.
|
||||||
|
|
||||||
- Issue #24452: Make webbrowser support Chrome on Mac OS X.
|
- Issue #24452: Make webbrowser support Chrome on Mac OS X.
|
||||||
|
|
||||||
- Issue #20766: Fix references leaked by pdb in the handling of SIGINT
|
- Issue #20766: Fix references leaked by pdb in the handling of SIGINT
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue