Thomas Kluyver added the comment: 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. ---------- Added file: http://bugs.python.org/file41626/zipfile-open-w.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26039> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com