Patchwork D10181: verify: convert an exception to bytes before logging

login
register
mail settings
Submitter phabricator
Date March 12, 2021, 6:09 p.m.
Message ID <differential-rev-PHID-DREV-uh227k2mo63fm5jhotf4-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48494/
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
  I'm not entirely sure why this code appears to be trying to convert twice, but
  it was flagged by pytype:
  
    File "/mnt/c/Users/Matt/hg/mercurial/verify.py", line 84, in _exc: Function _bytestr.__init__ was called with the wrong arguments [wrong-arg-types]
             Expected: (self, ints: Iterable[int])
      Actually passed: (self, ints: Exception)
      The following methods aren't implemented on Exception:
      __iter__

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/verify.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -14,6 +14,9 @@ 
     nullid,
     short,
 )
+from .utils import (
+    stringutil,
+)
 
 from . import (
     error,
@@ -81,7 +84,7 @@ 
 
     def _exc(self, linkrev, msg, inst, filename=None):
         """record exception raised during the verify process"""
-        fmsg = pycompat.bytestr(inst)
+        fmsg = stringutil.forcebytestr(inst)
         if not fmsg:
             fmsg = pycompat.byterepr(inst)
         self._err(linkrev, b"%s: %s" % (msg, fmsg), filename)