This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yudilevi
Recipients yudilevi
Date 2020-03-29.20:48:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585514903.71.0.609611507951.issue40105@roundup.psfhosted.org>
In-reply-to
Content
Updating the zip file comment to a shorter comment should truncate the zip file at the end of the new comment.
Instead, the new comment is written to the zip file but the file length stays the same.

For example, for a zip file that has the following zip comment:
b'This is my old amazing comment, I bet you really like it!' # 57 character long

Executing the following code:

zipFile = ZipFile(filePath, 'a')
zipFile.comment = b'My new shorter comment' # 22 character long
zipFile.close()

Will actually update the comment length in the zip header to the correct new length (22), but the bytecode will still have the following data:
b'My new shorter comment comment, I bet you really like it!'

Python reads the comment correctly since it relies on the comment length from the metadata (as far as I can tell), but the file is corrupt.

This is similar to the following old issue -
https://bugs.python.org/issue9239

But I wasn't sure whether to try and re-open that old one or create a new one.

Tested on version 3.8.2 (Windows 10).

Thanks!
History
Date User Action Args
2020-03-29 20:48:23yudilevisetrecipients: + yudilevi
2020-03-29 20:48:23yudilevisetmessageid: <1585514903.71.0.609611507951.issue40105@roundup.psfhosted.org>
2020-03-29 20:48:23yudilevilinkissue40105 messages
2020-03-29 20:48:23yudilevicreate