[New-bugs-announce] [issue7066] archive_util.make_archive doesn't restore the cwd if an error is raised
Ezio Melotti
report at bugs.python.org
Mon Oct 5 21:40:27 CEST 2009
New submission from Ezio Melotti <ezio.melotti at gmail.com>:
archive_util.make_archive() changes the value of the cwd, but if an
error is raised in "filename = func(base_name, base_dir, **kwargs)", the
cwd is not restored. This may happen if zlib is not available and causes
other ~60 tests to fail while running regrtest.py.
This trivial fix solve the problem here:
- filename = 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)
The new test_make_archive_owner_group() test added in r75192 also needs
a @unittest.skipUnless(zlib, "Requires zlib"), otherwise dist_distutils
fails.
Since half of this test doesn't require zlib (i.e. when 'tar' is used)
it might be a good idea to split the test in two, in order to test the
'tar' archives even if 'zlib' is not available.
(Thanks to R. David Murray - he spot the right place where the cwd is
changed and not restored.)
----------
assignee: tarek
components: Distutils
messages: 93618
nosy: ezio.melotti, r.david.murray, tarek
priority: normal
severity: normal
status: open
title: archive_util.make_archive doesn't restore the cwd if an error is raised
type: behavior
versions: Python 2.7, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7066>
_______________________________________
More information about the New-bugs-announce
mailing list