[PATCH 2 of 2] debuginstall: do not pass exception object to formatter (issue5676)
Yuya Nishihara
yuya at tcha.org
Thu Sep 7 09:54:29 EDT 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1504791414 -32400
# Thu Sep 07 22:36:54 2017 +0900
# Node ID 3573b95ec1f32805bde3a08b1f4f7dca8e3d699f
# Parent 5fda73a5468d3789bccdcb2da6d6b56e5ca2410b
debuginstall: do not pass exception object to formatter (issue5676)
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1000,7 +1000,7 @@ def debuginstall(ui, **opts):
try:
codecs.lookup(pycompat.sysstr(encoding.encoding))
except LookupError as inst:
- err = inst
+ err = util.forcebytestr(inst)
problems += 1
fm.condwrite(err, 'encodingerror', _(" %s\n"
" (check that your locale is properly set)\n"), err)
@@ -1056,7 +1056,7 @@ def debuginstall(ui, **opts):
)
dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
except Exception as inst:
- err = inst
+ err = util.forcebytestr(inst)
problems += 1
fm.condwrite(err, 'extensionserror', " %s\n", err)
@@ -1088,7 +1088,7 @@ def debuginstall(ui, **opts):
try:
templater.templater.frommapfile(m)
except Exception as inst:
- err = inst
+ err = util.forcebytestr(inst)
p = None
fm.condwrite(err, 'defaulttemplateerror', " %s\n", err)
else:
@@ -1124,7 +1124,7 @@ def debuginstall(ui, **opts):
try:
username = ui.username()
except error.Abort as e:
- err = e
+ err = util.forcebytestr(e)
problems += 1
fm.condwrite(username, 'username', _("checking username (%s)\n"), username)
diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -81,6 +81,14 @@ hg debuginstall with invalid encoding
checking encoding (invalidenc)...
unknown encoding: invalidenc
+exception message in JSON
+
+ $ HGENCODING=invalidenc HGUSER= hg debuginstall -Tjson | grep error
+ "defaulttemplateerror": null,
+ "encodingerror": "unknown encoding: invalidenc",
+ "extensionserror": null, (no-pure !)
+ "usernameerror": "no username supplied",
+
path variables are expanded (~ is the same as $TESTTMP)
$ mkdir tools
$ touch tools/testeditor.exe
More information about the Mercurial-devel
mailing list