Kaydet (Commit) 53fdb18b authored tarafından Tarek Ziadé's avatar Tarek Ziadé

Merged revisions 75662 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r75662 | tarek.ziade | 2009-10-24 15:38:27 +0200 (Sat, 24 Oct 2009) | 9 lines

  Merged revisions 75659 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r75659 | tarek.ziade | 2009-10-24 15:29:44 +0200 (Sat, 24 Oct 2009) | 1 line

    #7066 - Fixed distutils.archive_util.make_archive behavior so it restores the cwd
  ........
................
üst f6779fb1
...@@ -171,10 +171,11 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0, ...@@ -171,10 +171,11 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
func = format_info[0] func = format_info[0]
for arg, val in format_info[1]: for arg, val in format_info[1]:
kwargs[arg] = val kwargs[arg] = val
filename = func(base_name, base_dir, **kwargs) try:
filename = func(base_name, base_dir, **kwargs)
if root_dir is not None: finally:
log.debug("changing back to '%s'", save_cwd) if root_dir is not None:
os.chdir(save_cwd) log.debug("changing back to '%s'", save_cwd)
os.chdir(save_cwd)
return filename return filename
...@@ -8,7 +8,8 @@ from os.path import splitdrive ...@@ -8,7 +8,8 @@ from os.path import splitdrive
import warnings import warnings
from distutils.archive_util import (check_archive_formats, make_tarball, from distutils.archive_util import (check_archive_formats, make_tarball,
make_zipfile, make_archive) make_zipfile, make_archive,
ARCHIVE_FORMATS)
from distutils.spawn import find_executable, spawn from distutils.spawn import find_executable, spawn
from distutils.tests import support from distutils.tests import support
from test.support import check_warnings from test.support import check_warnings
...@@ -192,6 +193,20 @@ class ArchiveUtilTestCase(support.TempdirManager, ...@@ -192,6 +193,20 @@ class ArchiveUtilTestCase(support.TempdirManager,
base_name = os.path.join(tmpdir, 'archive') base_name = os.path.join(tmpdir, 'archive')
self.assertRaises(ValueError, make_archive, base_name, 'xxx') self.assertRaises(ValueError, make_archive, base_name, 'xxx')
def test_make_archive_cwd(self):
current_dir = os.getcwd()
def _breaks(*args, **kw):
raise RuntimeError()
ARCHIVE_FORMATS['xxx'] = (_breaks, [], 'xxx file')
try:
try:
make_archive('xxx', 'xxx', root_dir=self.mkdtemp())
except:
pass
self.assertEquals(os.getcwd(), current_dir)
finally:
del ARCHIVE_FORMATS['xxx']
def test_suite(): def test_suite():
return unittest.makeSuite(ArchiveUtilTestCase) return unittest.makeSuite(ArchiveUtilTestCase)
......
...@@ -1069,6 +1069,9 @@ Core and Builtins ...@@ -1069,6 +1069,9 @@ Core and Builtins
Library Library
------- -------
- Issue #7066: archive_util.make_archive now restores the cwd if an error is
raised. Initial patch by Ezio Melotti.
- Issue #6545: Removed assert statements in distutils.Extension, so the - Issue #6545: Removed assert statements in distutils.Extension, so the
behavior is similar when used with -O. behavior is similar when used with -O.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment