New submission from Dingyuan Wang:

The _make_zipfile in shutil uses ZIP_DEFLATED compression by default, and the 
fix introduced by #24982 adds directory entries. In zipfile.ZipFile.write, 
directories is added as 0 file_size, 0 compress_size, regardless of the 
compression method. Deflate will compress an empty string as \x03\x00, thus the 
directory entries become incorrect.

The command line interface of zipfile is correct. Shutil can be fixed as 
zipfile.main. As a directory entry with compression methods other than 
ZIP_STORED is meaningless, zipfile.write and (maybe) zipfile.writestr should 
always write a ZIP_STORED header for directory entries to avoid the above 
problem occuring by programming mistakes.

components: Library (Lib)
messages: 254647
nosy: gumblex
priority: normal
severity: normal
status: open
title: shutil.make_archive makes invalid directory entries
type: behavior
versions: Python 3.5

Python tracker <>
Python-bugs-list mailing list

Reply via email to