[Python-checkins] cpython (merge 3.3 -> default): merge 3.3 (#20102)
benjamin.peterson
python-checkins at python.org
Sun Feb 2 21:31:28 CET 2014
http://hg.python.org/cpython/rev/20aa07f93ca7
changeset: 88902:20aa07f93ca7
parent: 88899:558b26b6a342
parent: 88901:838674d15b5b
user: Benjamin Peterson <benjamin at python.org>
date: Sun Feb 02 15:31:07 2014 -0500
summary:
merge 3.3 (#20102)
files:
Lib/shutil.py | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/Lib/shutil.py b/Lib/shutil.py
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -679,17 +679,15 @@
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
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list