Message258313
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. |
|
Date |
User |
Action |
Args |
2016-01-15 17:54:07 | takluyver | set | recipients:
+ takluyver, serhiy.storchaka, mbussonn |
2016-01-15 17:54:06 | takluyver | set | messageid: <1452880446.6.0.37739738606.issue26039@psf.upfronthosting.co.za> |
2016-01-15 17:54:06 | takluyver | link | issue26039 messages |
2016-01-15 17:54:06 | takluyver | create | |
|