changeset 46696:ed0899e01628 stable

verify: convert an exception to bytes before logging 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__ Differential Revision: https://phab.mercurial-scm.org/D10181
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 11 Mar 2021 21:02:03 -0500
parents 8da44c36fc74
children 71443f742886
files mercurial/verify.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/verify.py	Thu Mar 11 19:50:14 2021 -0500
+++ b/mercurial/verify.py	Thu Mar 11 21:02:03 2021 -0500
@@ -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)