bpo-40105: ZipFile truncate in append mode with shorter comment (GH-19337)

(cherry picked from commit ff9147d93b)

Co-authored-by: Jan Mazur <16736821+mzr@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2020-09-28 13:18:47 -07:00 committed by GitHub
parent bdf46bc7e1
commit 048f54dc75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 0 deletions

View file

@ -1918,6 +1918,8 @@ class ZipFile:
centDirSize, centDirOffset, len(self._comment))
self.fp.write(endrec)
self.fp.write(self._comment)
if self.mode == "a":
self.fp.truncate()
self.fp.flush()
def _fpclose(self, fp):