Patchwork D10173: grep: convert an exception to bytes for a warning message

login
register
mail settings
Submitter phabricator
Date March 12, 2021, 6:09 p.m.
Message ID <differential-rev-PHID-DREV-bexnrudl43aannzm4dbo-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48495/
State Superseded
Headers show

Comments

phabricator - March 12, 2021, 6:09 p.m.
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/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__

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D10173

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3444,7 +3444,8 @@ 
         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'