Mercurial > hg
comparison mercurial/archival.py @ 40247:844deb408a5b
archival: don't try and fsdecode non-{bytes,str} objects
This function accepts both bytes and file-like objects.
Differential Revision: https://phab.mercurial-scm.org/D5073
author | Augie Fackler <augie@google.com> |
---|---|
date | Sat, 13 Oct 2018 07:51:22 -0400 |
parents | d739f423bf06 |
children | 3d76a8e627a6 |
comparison
equal
deleted
inserted
replaced
40246:be0a5d2d5c78 | 40247:844deb408a5b |
---|---|
201 class zipit(object): | 201 class zipit(object): |
202 '''write archive to zip file or stream. can write uncompressed, | 202 '''write archive to zip file or stream. can write uncompressed, |
203 or compressed with deflate.''' | 203 or compressed with deflate.''' |
204 | 204 |
205 def __init__(self, dest, mtime, compress=True): | 205 def __init__(self, dest, mtime, compress=True): |
206 self.z = zipfile.ZipFile(pycompat.fsdecode(dest), r'w', | 206 if isinstance(dest, bytes): |
207 dest = pycompat.fsdecode(dest) | |
208 self.z = zipfile.ZipFile(dest, r'w', | |
207 compress and zipfile.ZIP_DEFLATED or | 209 compress and zipfile.ZIP_DEFLATED or |
208 zipfile.ZIP_STORED) | 210 zipfile.ZIP_STORED) |
209 | 211 |
210 # Python's zipfile module emits deprecation warnings if we try | 212 # Python's zipfile module emits deprecation warnings if we try |
211 # to store files with a date before 1980. | 213 # to store files with a date before 1980. |