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

login
register
mail settings
Submitter phabricator
Date Sept. 21, 2021, 3:38 p.m.
Message ID <differential-rev-PHID-DREV-qd5nw2qun66mlac7qpa3-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49787/
State Superseded
Headers show

Comments

phabricator - Sept. 21, 2021, 3:38 p.m.
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




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

Patch

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)