[Python-checkins] cpython (2.7): Guard shutil._make_archive against a logger=None argument.
eric.araujo
python-checkins at python.org
Fri Aug 19 14:28:12 CEST 2011
http://hg.python.org/cpython/rev/615a29295d5f
changeset: 71956:615a29295d5f
branch: 2.7
user: Éric Araujo <merwok at netwok.org>
date: Fri Aug 19 03:07:39 2011 +0200
summary:
Guard shutil._make_archive against a logger=None argument.
Backporting two lines from the 3.x tests was enough to trigger the bug.
I also took the opportunity of making the logging call lazy.
files:
Lib/shutil.py | 3 ++-
Lib/test/test_shutil.py | 4 ++++
Misc/NEWS | 2 ++
3 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/Lib/shutil.py b/Lib/shutil.py
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -359,7 +359,8 @@
archive_dir = os.path.dirname(archive_name)
if not os.path.exists(archive_dir):
- logger.info("creating %s" % archive_dir)
+ if logger is not None:
+ logger.info("creating %s", archive_dir)
if not dry_run:
os.makedirs(archive_dir)
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -349,6 +349,8 @@
self.write_file([tmpdir, 'sub', 'file3'], 'xxx')
tmpdir2 = self.mkdtemp()
+ # force shutil to create the directory
+ os.rmdir(tmpdir2)
unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
"source and target should be on same drive")
@@ -464,6 +466,8 @@
self.write_file([tmpdir, 'file2'], 'xxx')
tmpdir2 = self.mkdtemp()
+ # force shutil to create the directory
+ os.rmdir(tmpdir2)
base_name = os.path.join(tmpdir2, 'archive')
_make_zipfile(base_name, tmpdir)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,8 @@
Library
-------
+- Issue #9173: Let shutil._make_archive work if the logger argument is None.
+
- Issue #12650: Fix a race condition where a subprocess.Popen could leak
resources (FD/zombie) when killed at the wrong time.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list