[issue11980] zipfile.ZipFile.write should accept fp as argument

Terry J. Reedy report at bugs.python.org
Sat May 7 03:20:40 CEST 2011


Terry J. Reedy <tjreedy at udel.edu> added the comment:

zipfile.ZipFile takes a file arg that can be a 'path to a file (a string) or a file-like object'. The .write() method takes a filename arg. I would think that the proposal should be what the title says, to expand that to a file arg, either a path or 'file', as with ZipFile itself. I cannot think of any reason not to do that.

The patch adds a separate .writefp method with the file and arcname switched and the compression_type omitted. The code is mostly a duplicated subset of .write. While is proves the concept, none of the differences strike me as good. I think instead there should just be one method that branches, where appropriate, on the type of 'file', just as ZipFile.__init__ does. I admit that I do not understand what .write is supposed to do or does do when filename is a directory.

The patch includes a test. It still needs doc and News patches, but those come after the basic patch is done.

----------
nosy: +alanmcintyre, terry.reedy
stage:  -> patch review
versions: +Python 3.3 -Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11980>
_______________________________________


More information about the Python-bugs-list mailing list