Patchwork D2541: verify: fix exception formatting bug in Python 3

login
register
mail settings
Submitter phabricator
Date March 2, 2018, 2:50 p.m.
Message ID <differential-rev-PHID-DREV-2vwoy4djz2vaxazxbrly-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28667/
State Superseded
Headers show

Comments

phabricator - March 2, 2018, 2:50 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/verify.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - March 2, 2018, 3:55 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  According to https://phab.mercurial-scm.org/rHG12998fd17fbc9a26ac144da32c66368b7c11dc0a, the original intent was to use repr() if str(inst)  was empty.
  
  Needs `pycompat.byterepr(inst)` if `util.forcebytestr(inst)` is empty.

REPOSITORY
  rHG Mercurial

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

To: durin42, #hg-reviewers, pulkit, yuja
Cc: yuja, mercurial-devel
phabricator - March 2, 2018, 7:34 p.m.
yuja accepted this revision.
yuja added inline comments.
This revision is now accepted and ready to land.

INLINE COMMENTS

> verify.py:76
> +            fmsg = pycompat.byterepr(inst)
>          self.err(linkrev, "%s: %s" % (msg, inst), filename)
>  

s/inst/fmsg/ and queued, thanks.

REPOSITORY
  rHG Mercurial

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

To: durin42, #hg-reviewers, pulkit, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -70,8 +70,7 @@ 
         self.errors += 1
 
     def exc(self, linkrev, msg, inst, filename=None):
-        if not str(inst):
-            inst = repr(inst)
+        inst = util.forcebytestr(inst)
         self.err(linkrev, "%s: %s" % (msg, inst), filename)
 
     def checklog(self, obj, name, linkrev):