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 BoppreH
Recipients BoppreH, paul.moore, steve.dower, tim.golden, zach.ware
Date 2017-04-30.01:33:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1493515995.55.0.223691905377.issue30213@psf.upfronthosting.co.za>
In-reply-to
Content
I may be misunderstanding file modes or the `zipfile` library, but

    from zipfile import ZipFile
    ZipFile(open('a.zip', 'ab'), 'a').writestr('f.txt', 'z')

unexpectedly creates an invalid zip file. 7zip is able to open and show the file list, but files inside look empty, and Windows simply says it's invalid. 

Changing the file mode from `ab` to `wb+` fixes the problem, but truncates the file, and `rb+` doesn't create the file. Calling `close` on both the `open` and `ZipFile` doesn't help either. Using `ZipFile(...).open` instead of `writestr` has the same problem.

I could only reproduce this on [Windows 10, Python 3.6.1, 64 bit]. The zip file was proper on [Windows 10, Python 3.3.5, 32 bit], [Windows 10 Bash, Python 3.4.3, 64 bit], and [FreeBSD, Python 3.5.3, 64 bit].

This is my first bug report, so forgive me if I made any mistakes.
History
Date User Action Args
2017-04-30 01:33:15BoppreHsetrecipients: + BoppreH, paul.moore, tim.golden, zach.ware, steve.dower
2017-04-30 01:33:15BoppreHsetmessageid: <1493515995.55.0.223691905377.issue30213@psf.upfronthosting.co.za>
2017-04-30 01:33:15BoppreHlinkissue30213 messages
2017-04-30 01:33:14BoppreHcreate