From patchwork Tue Sep 21 15:38:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D11472: archival: force a `CompressionError` to bytes before passing to `error.Abort` From: phabricator X-Patchwork-Id: 49787 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 21 Sep 2021 15:38:50 +0000 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 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)