D11472: archival: force a `CompressionError` to bytes before passing to `error.Abort`

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Tue Sep 21 15:38:50 UTC 2021


mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I'm not sure what changed before pytype 09-09-2021 (from 04-15-2021), but this
  started getting flagged.
  
  This fixes:
  
    File "/mnt/c/Users/Matt/hg/mercurial/archival.py", line 199, in taropen: Function bytestr.__init__ was called with the wrong arguments [wrong-arg-types]
             Expected: (self, ints: Iterable[int])
      Actually passed: (self, ints: tarfile.CompressionError)
      Attributes of protocol Iterable[int] are not implemented on tarfile.CompressionError: __iter__

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -29,6 +29,8 @@
     vfs as vfsmod,
 )
 
+from .utils import stringutil
+
 stringio = util.stringio
 
 # from unzip source code:
@@ -196,7 +198,7 @@
                         name, pycompat.sysstr(mode + kind), fileobj
                     )
                 except tarfile.CompressionError as e:
-                    raise error.Abort(pycompat.bytestr(e))
+                    raise error.Abort(stringutil.forcebytestr(e))
 
         if isinstance(dest, bytes):
             self.z = taropen(b'w:', name=dest)



To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list