GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Issue #25624: ZipFile now always writes a ZIP_STORED header for direc… · python/cpython@5323ed3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib
    • test
      • test_shutil.py
    • zipfile.py
  • Misc
    • ACKS
    • NEWS
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/test_shutil.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_shutil.py
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,29 @@ def test_zipfile_vs_zip(self):
511511
names2 = zf.namelist()
512512
self.assertEqual(sorted(names), sorted(names2))
513513

514+
@unittest.skipUnless(zlib, "Requires zlib")
515+
@unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
516+
@unittest.skipUnless(find_executable('unzip'),
517+
'Need the unzip command to run')
518+
def test_unzip_zipfile(self):
519+
root_dir, base_dir = self._create_files()
520+
base_name = os.path.join(self.mkdtemp(), 'archive')
521+
archive = make_archive(base_name, 'zip', root_dir, base_dir)
522+
523+
# check if ZIP file was created
524+
self.assertEqual(archive, base_name + '.zip')
525+
self.assertTrue(os.path.isfile(archive))
526+
527+
# now check the ZIP file using `unzip -t`
528+
zip_cmd = ['unzip', '-t', archive]
529+
with support.change_cwd(root_dir):
530+
try:
531+
subprocess.check_output(zip_cmd, stderr=subprocess.STDOUT)
532+
except subprocess.CalledProcessError as exc:
533+
details = exc.output
534+
msg = "{}\n\n**Unzip Output**\n{}"
535+
self.fail(msg.format(exc, details))
536+
514537
def test_make_archive(self):
515538
tmpdir = self.mkdtemp()
516539
base_name = os.path.join(tmpdir, 'archive')
Collapse file

‎Lib/zipfile.py‎

Copy file name to clipboardExpand all lines: Lib/zipfile.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,9 @@ def write(self, filename, arcname=None, compress_type=None):
11341134
arcname += '/'
11351135
zinfo = ZipInfo(arcname, date_time)
11361136
zinfo.external_attr = (st[0] & 0xFFFF) << 16L # Unix attributes
1137-
if compress_type is None:
1137+
if isdir:
1138+
zinfo.compress_type = ZIP_STORED
1139+
elif compress_type is None:
11381140
zinfo.compress_type = self.compression
11391141
else:
11401142
zinfo.compress_type = compress_type
Collapse file

‎Misc/ACKS‎

Copy file name to clipboardExpand all lines: Misc/ACKS
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,7 @@ Richard Walker
14431443
Larry Wall
14441444
Kevin Walzer
14451445
Rodrigo Steinmuller Wanderley
1446+
Dingyuan Wang
14461447
Ke Wang
14471448
Greg Ward
14481449
Tom Wardill
Collapse file

‎Misc/NEWS‎

Copy file name to clipboardExpand all lines: Misc/NEWS
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Core and Builtins
1313
Library
1414
-------
1515

16+
- Issue #25624: ZipFile now always writes a ZIP_STORED header for directory
17+
entries. Patch by Dingyuan Wang.
18+
1619

1720
What's New in Python 2.7.11 release candidate 1?
1821
================================================

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.