diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-02-02 20:31:07 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-02-02 20:31:07 (GMT) |
commit | 85f107443814b250c1396969aa060ec3ec26d4db (patch) | |
tree | 6d39757a1445e28555b2c0761449ee6e555e9cf2 | |
parent | a56d4e8ea180c32bf62855e75fc3728885e02914 (diff) | |
parent | 091d386f7877ee1a37475dddc6ad845f5b70e4a2 (diff) | |
download | cpython-85f107443814b250c1396969aa060ec3ec26d4db.zip cpython-85f107443814b250c1396969aa060ec3ec26d4db.tar.gz cpython-85f107443814b250c1396969aa060ec3ec26d4db.tar.bz2 |
merge 3.3 (#20102)
-rw-r--r-- | Lib/shutil.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py index 502bb67..9a6a040 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -679,17 +679,15 @@ def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None): zip_filename, base_dir) if not dry_run: - zip = zipfile.ZipFile(zip_filename, "w", - compression=zipfile.ZIP_DEFLATED) - - for dirpath, dirnames, filenames in os.walk(base_dir): - for name in filenames: - path = os.path.normpath(os.path.join(dirpath, name)) - if os.path.isfile(path): - zip.write(path, path) - if logger is not None: - logger.info("adding '%s'", path) - zip.close() + with zipfile.ZipFile(zip_filename, "w", + compression=zipfile.ZIP_DEFLATED) as zf: + for dirpath, dirnames, filenames in os.walk(base_dir): + for name in filenames: + path = os.path.normpath(os.path.join(dirpath, name)) + if os.path.isfile(path): + zf.write(path, path) + if logger is not None: + logger.info("adding '%s'", path) return zip_filename |