Issue7066
Created on 2009-10-05 19:40 by ezio.melotti, last changed 2009-10-24 13:45 by tarek.
| Messages (4) | |||
|---|---|---|---|
| msg93618 - (view) | Author: Ezio Melotti (ezio.melotti) | Date: 2009-10-05 19:40 | |
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.)
|
|||
| msg93622 - (view) | Author: Tarek Ziadé (tarek) | Date: 2009-10-05 21:25 | |
I see two distinct points (besides test_make_archive_owner_group): 1- having a try..finally when changing the current working dir (I'll do this thanks for the patch) 2- dealing with calls made on archive_util.make_archive() when zlib is not available. What error do you get ? CompressionError I guess ? |
|||
| msg93624 - (view) | Author: Ezio Melotti (ezio.melotti) | Date: 2009-10-05 21:27 | |
====================================================================== ERROR: test_make_archive_owner_group (distutils.tests.test_archive_util.ArchiveUtilTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/wolf/dev/trunk/Lib/distutils/tests/test_archive_util.py", line 224, in test_make_archive_owner_group group=group) File "/home/wolf/dev/trunk/Lib/distutils/archive_util.py", line 237, in make_archive filename = func(base_name, base_dir, **kwargs) File "/home/wolf/dev/trunk/Lib/distutils/archive_util.py", line 163, in make_zipfile compression=zipfile.ZIP_DEFLATED) File "/home/wolf/dev/trunk/Lib/zipfile.py", line 675, in __init__ "Compression requires the (missing) zlib module" RuntimeError: Compression requires the (missing) zlib module |
|||
| msg94415 - (view) | Author: Tarek Ziadé (tarek) | Date: 2009-10-24 13:45 | |
Done in r75659, r75662 and r75663 (merge in 2.6 maint. waiting for 2.6.4 final tag to be done) Thanks ! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2009-10-24 13:45:32 | tarek | set | status: open -> closed messages: + msg94415 versions: + Python 2.6, Python 3.1 |
| 2009-10-05 21:27:15 | ezio.melotti | set | messages: + msg93624 |
| 2009-10-05 21:25:15 | tarek | set | messages: + msg93622 |
| 2009-10-05 20:48:56 | tarek | set | resolution: accepted |
| 2009-10-05 19:40:26 | ezio.melotti | create | |