cpython: de5582c569ff (original) (raw)
Mercurial > cpython
changeset 99287:de5582c569ff 2.7
Issue #25624: ZipFile now always writes a ZIP_STORED header for directory entries. Patch by Dingyuan Wang. [#25624]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Sun, 22 Nov 2015 14:56:22 +0200 |
parents | c33e4881721f |
children | d452cf840e5b |
files | Lib/test/test_shutil.py Lib/zipfile.py Misc/ACKS Misc/NEWS |
diffstat | 4 files changed, 30 insertions(+), 1 deletions(-)[+] [-] Lib/test/test_shutil.py 23 Lib/zipfile.py 4 Misc/ACKS 1 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -511,6 +511,29 @@ class TestShutil(unittest.TestCase): names2 = zf.namelist() self.assertEqual(sorted(names), sorted(names2))
- @unittest.skipUnless(zlib, "Requires zlib")
- @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
- @unittest.skipUnless(find_executable('unzip'),
'Need the unzip command to run')[](#l1.10)
- def test_unzip_zipfile(self):
root_dir, base_dir = self._create_files()[](#l1.12)
base_name = os.path.join(self.mkdtemp(), 'archive')[](#l1.13)
archive = make_archive(base_name, 'zip', root_dir, base_dir)[](#l1.14)
# check if ZIP file was created[](#l1.16)
self.assertEqual(archive, base_name + '.zip')[](#l1.17)
self.assertTrue(os.path.isfile(archive))[](#l1.18)
# now check the ZIP file using `unzip -t`[](#l1.20)
zip_cmd = ['unzip', '-t', archive][](#l1.21)
with support.change_cwd(root_dir):[](#l1.22)
try:[](#l1.23)
subprocess.check_output(zip_cmd, stderr=subprocess.STDOUT)[](#l1.24)
except subprocess.CalledProcessError as exc:[](#l1.25)
details = exc.output[](#l1.26)
msg = "{}\n\n**Unzip Output**\n{}"[](#l1.27)
self.fail(msg.format(exc, details))[](#l1.28)
+ def test_make_archive(self): tmpdir = self.mkdtemp() base_name = os.path.join(tmpdir, 'archive')
--- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1134,7 +1134,9 @@ class ZipFile(object): arcname += '/' zinfo = ZipInfo(arcname, date_time) zinfo.external_attr = (st[0] & 0xFFFF) << 16L # Unix attributes
if compress_type is None:[](#l2.7)
if isdir:[](#l2.8)
zinfo.compress_type = ZIP_STORED[](#l2.9)
elif compress_type is None:[](#l2.10) zinfo.compress_type = self.compression[](#l2.11) else:[](#l2.12) zinfo.compress_type = compress_type[](#l2.13)
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -1443,6 +1443,7 @@ Richard Walker Larry Wall Kevin Walzer Rodrigo Steinmuller Wanderley +Dingyuan Wang Ke Wang Greg Ward Tom Wardill
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -13,6 +13,9 @@ Core and Builtins Library ------- +- Issue #25624: ZipFile now always writes a ZIP_STORED header for directory