]> granicus.if.org Git - python/commitdiff
Guard shutil._make_archive against a logger=None argument.
authorÉric Araujo <merwok@netwok.org>
Fri, 19 Aug 2011 01:07:39 +0000 (03:07 +0200)
committerÉric Araujo <merwok@netwok.org>
Fri, 19 Aug 2011 01:07:39 +0000 (03:07 +0200)
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.

Lib/shutil.py
Lib/test/test_shutil.py
Misc/NEWS

index 9d922fbefc3f4d8f3e09167e0d5a9df19cd39db0..59a38fef76e30473a601e579311be9891dac5fac 100644 (file)
@@ -359,7 +359,8 @@ def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
     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)
 
index 9f9bf45e42daa24ea34a0e655e163866c77b68e3..b4e5415c0a8f4663fc7bb0db0694ad67ac6a36ab 100644 (file)
@@ -349,6 +349,8 @@ class TestShutil(unittest.TestCase):
         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 @@ class TestShutil(unittest.TestCase):
         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)
 
index 679b4b070452bcaac7c67a98890333aa87053820..78f4fa6c8d0ce48f39e3aa306dc27bc58fb98464 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,8 @@ Core and Builtins
 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.