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 takluyver
Recipients mbussonn, serhiy.storchaka, takluyver
Date 2016-01-15.17:54:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1452880446.6.0.37739738606.issue26039@psf.upfronthosting.co.za>
In-reply-to
Content
Attached is a first go at a patch enabling zipfile.open(blah, mode='w')

Files must be written sequentially, so you have to close one writing handle before opening another. If you try to open a second one before closing the first, it will raise RuntimeError. I considered doing something where it would write to temporary files and add them to the zip file when they were closed, but it seemed like a bad idea.

You can almost certainly break this by reading from a zip file while there's an open writing handle. Resolving this is tricky because there's a disconnect in the requirements for reading and writing: writing allows for a non-seekable output stream, but reading assumes that you can seek freely. The simplest fix is to block reading while there is an open file handle. I don't think many people will need to read one file from a zip while writing another, anyway.

I have used the lock, but I haven't thought carefully about thread safety, so that should still be checked carefully.
History
Date User Action Args
2016-01-15 17:54:07takluyversetrecipients: + takluyver, serhiy.storchaka, mbussonn
2016-01-15 17:54:06takluyversetmessageid: <1452880446.6.0.37739738606.issue26039@psf.upfronthosting.co.za>
2016-01-15 17:54:06takluyverlinkissue26039 messages
2016-01-15 17:54:06takluyvercreate