D5073: archival: don't try and fsdecode non-{bytes,str} objects

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Sat Oct 13 11:57:32 UTC 2018


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This function accepts both bytes and file-like objects.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5073

AFFECTED FILES
  mercurial/archival.py

CHANGE DETAILS

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -203,7 +203,9 @@
     or compressed with deflate.'''
 
     def __init__(self, dest, mtime, compress=True):
-        self.z = zipfile.ZipFile(pycompat.fsdecode(dest), r'w',
+        if isinstance(dest, bytes):
+            dest = pycompat.fsdecode(dest)
+        self.z = zipfile.ZipFile(dest, r'w',
                                  compress and zipfile.ZIP_DEFLATED or
                                  zipfile.ZIP_STORED)
 



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list