]> granicus.if.org Git - python/commitdiff
Merged revisions 75659 via svnmerge from
authorR. David Murray <rdmurray@bitdance.com>
Sun, 1 Aug 2010 01:53:52 +0000 (01:53 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Sun, 1 Aug 2010 01:53:52 +0000 (01:53 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

Only the try/except was backported; owner and group were added in 2.7,
as was the test file.

........
  r75659 | tarek.ziade | 2009-10-24 09:29:44 -0400 (Sat, 24 Oct 2009) | 1 line

  #7066 - Fixed distutils.archive_util.make_archive behavior so it restores the cwd
........

Lib/distutils/archive_util.py
Misc/NEWS

index 264e66faf2171309556d5d681aa731df95a9d00f..251c0df4e98763e040811589e8979a2a27288717 100644 (file)
@@ -162,9 +162,12 @@ def make_archive (base_name, format,
         kwargs[arg] = val
     filename = apply(func, (base_name, base_dir), kwargs)
 
-    if root_dir is not None:
-        log.debug("changing back to '%s'", save_cwd)
-        os.chdir(save_cwd)
+    try:
+        filename = func(base_name, base_dir, **kwargs)
+    finally:
+        if root_dir is not None:
+            log.debug("changing back to '%s'", save_cwd)
+            os.chdir(save_cwd)
 
     return filename
 
index ad25699ecb3feb366110240d5d8072c67493d309..307c3329790ffac3aec533db360774b3df5855f7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -84,6 +84,9 @@ C-API
 Library
 -------
 
+- Issue #7066: archive_util.make_archive now restores the cwd if an error is 
+  raised. Initial patch by Ezio Melotti.
+
 - Issue #5006: Better handling of unicode byte-order marks (BOM) in the io
   library. This means, for example, that opening an UTF-16 text file in append
   mode doesn't add a BOM at the end of the file if the file isn't empty.