# HG changeset patch # User Matt Harbison # Date 2021-03-11 22:16:29 # Node ID 7e02e7c721b043bd7b25125521f00c36e74a920b # Parent 83ffc49f7e48c2d4e5217aca932b39208269c0bd grep: convert an exception to bytes for a warning message Caught by pytype: File "/mnt/c/Users/Matt/hg/mercurial/commands.py", line 3457, in grep: Function _bytestr.__init__ was called with the wrong arguments [wrong-arg-types] Expected: (self, ints: Iterable[int]) Actually passed: (self, ints: re.error) The following methods aren't implemented on re.error: __iter__ Differential Revision: https://phab.mercurial-scm.org/D10173 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3444,7 +3444,8 @@ def grep(ui, repo, pattern, *pats, **opt regexp = util.re.compile(pattern, reflags) except re.error as inst: ui.warn( - _(b"grep: invalid match pattern: %s\n") % pycompat.bytestr(inst) + _(b"grep: invalid match pattern: %s\n") + % stringutil.forcebytestr(inst) ) return 1 sep, eol = b':', b'\n'