Patchwork D7191: py3: fix exception display encoding in contrib/simplemerge.py

login
register
mail settings
Submitter phabricator
Date Nov. 1, 2019, 4:46 p.m.
Message ID <differential-rev-PHID-DREV-tpolawkoc2hc63x2splb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42656/
State Superseded
Headers show

Comments

phabricator - Nov. 1, 2019, 4:46 p.m.
touilleMan created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/simplemerge

CHANGE DETAILS




To: touilleMan, #hg-reviewers
Cc: mjpieters, mercurial-devel

Patch

diff --git a/contrib/simplemerge b/contrib/simplemerge
--- a/contrib/simplemerge
+++ b/contrib/simplemerge
@@ -18,6 +18,7 @@ 
 )
 from mercurial.utils import (
     procutil,
+    stringutil
 )
 
 options = [(b'L', b'label', [], _(b'labels to use on conflict markers')),
@@ -75,8 +76,7 @@ 
                                      context.arbitraryfilectx(other),
                                      **pycompat.strkwargs(opts)))
 except ParseError as e:
-    if pycompat.ispy3:
-        e = str(e).encode('utf8')
+    e = stringutil.forcebytestr(e)
     pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e))
     showhelp()
     sys.exit(1)