# HG changeset patch # User Matt Harbison # Date 1632148958 14400 # Node ID 28c62f83b65228fc2b22168ea256c4cae8fdbbb3 # Parent 1fda8c9358ce8eede8f183519fcacd1eef5af388 encoding: force a few Errors to bytes before passing to `error.Abort` I'm not sure what changed before pytype 09-09-2021 (from 04-15-2021), but these started getting flagged. PyCharm also flagged these. This fixes the following: File "/mnt/c/Users/Matt/hg/mercurial/encoding.py", line 243, in fromlocal: Function Abort.__init__ was called with the wrong arguments [wrong-arg-types] Expected: (self, message: Union[bytearray, bytes, memoryview], ...) Actually passed: (self, message: LookupError, ...) File "/mnt/c/Users/Matt/hg/mercurial/encoding.py", line 309, in lower: Function Abort.__init__ was called with the wrong arguments [wrong-arg-types] Expected: (self, message: Union[bytearray, bytes, memoryview], ...) Actually passed: (self, message: LookupError, ...) File "/mnt/c/Users/Matt/hg/mercurial/encoding.py", line 336, in upperfallback: Function Abort.__init__ was called with the wrong arguments [wrong-arg-types] Expected: (self, message: Union[bytearray, bytes, memoryview], ...) Actually passed: (self, message: LookupError, ...) Called from (traceback): line 391, in current file line 348, in get line 318, in upper Differential Revision: https://phab.mercurial-scm.org/D11467 diff -r 1fda8c9358ce -r 28c62f83b652 mercurial/encoding.py --- a/mercurial/encoding.py Tue Sep 21 00:16:35 2021 -0400 +++ b/mercurial/encoding.py Mon Sep 20 10:42:38 2021 -0400 @@ -240,7 +240,9 @@ b"decoding near '%s': %s!" % (sub, pycompat.bytestr(inst)) ) except LookupError as k: - raise error.Abort(k, hint=b"please check your locale settings") + raise error.Abort( + pycompat.bytestr(k), hint=b"please check your locale settings" + ) def unitolocal(u): @@ -306,7 +308,9 @@ except UnicodeError: return s.lower() # we don't know how to fold this except in ASCII except LookupError as k: - raise error.Abort(k, hint=b"please check your locale settings") + raise error.Abort( + pycompat.bytestr(k), hint=b"please check your locale settings" + ) def upper(s): @@ -333,7 +337,9 @@ except UnicodeError: return s.upper() # we don't know how to fold this except in ASCII except LookupError as k: - raise error.Abort(k, hint=b"please check your locale settings") + raise error.Abort( + pycompat.bytestr(k), hint=b"please check your locale settings" + ) if not _nativeenviron: