summaryrefslogtreecommitdiffstats
path: root/Lib/shutil.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-09-08 02:51:00 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-09-08 02:51:00 (GMT)
commitd941d7a586c8ea2f8253d7b238b3a56522b77a83 (patch)
tree3298e5e5255c20805314bd0d8887d3f3f4cb712e /Lib/shutil.py
parent6c8b66cd261c6418566700527784b17bb459db1f (diff)
parent2504cecebdff16588d7b753843f4a856c510851e (diff)
downloadcpython-d941d7a586c8ea2f8253d7b238b3a56522b77a83.zip
cpython-d941d7a586c8ea2f8253d7b238b3a56522b77a83.tar.gz
cpython-d941d7a586c8ea2f8253d7b238b3a56522b77a83.tar.bz2
Issue #24982: shutil.make_archive() with the "zip" format now adds entries
for directories (including empty directories) in ZIP file. Added test for comparing shutil.make_archive() with the "zip" command.
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r--Lib/shutil.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index a5da587..3f4b6bf 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -679,7 +679,16 @@ def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None):
if not dry_run:
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)
for dirpath, dirnames, filenames in os.walk(base_dir):
+ for name in sorted(dirnames):
+ path = os.path.normpath(os.path.join(dirpath, name))
+ zf.write(path, path)
+ if logger is not None:
+ logger.info("adding '%s'", path)
for name in filenames:
path = os.path.normpath(os.path.join(dirpath, name))
if os.path.isfile(path):