# HG changeset patch # User Matt Harbison # Date 2021-03-11 23:09:55 # Node ID 1099541b64623adfc33a512200bef2cf737d6a32 # Parent 90a92f041fc69041018145c7d85ec47632918f9f hg: convert an exception to bytes in the repo creation exception handler 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]) Differential Revision: https://phab.mercurial-scm.org/D10176 diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -41,7 +41,6 @@ from . import ( mergestate as mergestatemod, narrowspec, phases, - pycompat, requirements, scmutil, sshpeer, @@ -53,7 +52,11 @@ from . import ( verify as verifymod, vfs as vfsmod, ) -from .utils import hashutil +from .utils import ( + hashutil, + stringutil, +) + release = lock.release @@ -74,7 +77,7 @@ def _local(path): # 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