summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2010-02-07 20:24:02 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2010-02-07 20:24:02 (GMT)
commitee5c885fd2446dea7269c65248312a0856f50fd3 (patch)
tree2d2fdd42b64d0febbe419f35087e866c0ca0f5c9 /Lib/zipfile.py
parent755740f3ea9c5005d16a80c07e7fc26e45f11aa1 (diff)
downloadcpython-ee5c885fd2446dea7269c65248312a0856f50fd3.zip
cpython-ee5c885fd2446dea7269c65248312a0856f50fd3.tar.gz
cpython-ee5c885fd2446dea7269c65248312a0856f50fd3.tar.bz2
Merged revisions 78097 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78097 | ronald.oussoren | 2010-02-07 21:18:02 +0100 (Sun, 07 Feb 2010) | 2 lines Issue 6003: ZipFile.writestr "compression_type" argument ........
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index d5caf26..2982ec3 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -1065,7 +1065,7 @@ class ZipFile:
self.filelist.append(zinfo)
self.NameToInfo[zinfo.filename] = zinfo
- def writestr(self, zinfo_or_arcname, data):
+ def writestr(self, zinfo_or_arcname, data, compress_type=None):
"""Write a file into the archive. The contents is 'data', which
may be either a 'str' or a 'bytes' instance; if it is a 'str',
it is encoded as UTF-8 first.
@@ -1087,6 +1087,9 @@ class ZipFile:
zinfo.file_size = len(data) # Uncompressed size
zinfo.header_offset = self.fp.tell() # Start of header data
+ if compress_type is not None:
+ zinfo.compress_type = compress_type
+
self._writecheck(zinfo)
self._didModify = True
zinfo.CRC = crc32(data) & 0xffffffff # CRC-32 checksum