From patchwork Fri Mar 12 18:09:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D10176: hg: convert an exception to bytes in the repo creation exception handler From: phabricator X-Patchwork-Id: 48489 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Fri, 12 Mar 2021 18:09:33 +0000 mharbison72 created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY Caught by pytype: File "/mnt/c/Users/Matt/hg/mercurial/hg.py", line 77, in _local: Function _bytestr.__init__ was called with the wrong arguments [wrong-arg-types] Expected: (self, ints: Iterable[int]) Actually passed: (self, ints: Union[TypeError, ValueError]) REPOSITORY rHG Mercurial BRANCH stable REVISION DETAIL https://phab.mercurial-scm.org/D10176 AFFECTED FILES mercurial/hg.py CHANGE DETAILS To: mharbison72, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -41,7 +41,6 @@ mergestate as mergestatemod, narrowspec, phases, - pycompat, requirements, scmutil, sshpeer, @@ -53,7 +52,11 @@ verify as verifymod, vfs as vfsmod, ) -from .utils import hashutil +from .utils import ( + hashutil, + stringutil, +) + release = lock.release @@ -74,7 +77,7 @@ # Python 2 raises TypeError, Python 3 ValueError. except (TypeError, ValueError) as e: raise error.Abort( - _(b'invalid path %s: %s') % (path, pycompat.bytestr(e)) + _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e)) ) except OSError: isfile = False