# HG changeset patch # User Yuya Nishihara # Date 1504791414 -32400 # Node ID ada8a19672ab21b411801118f5cefad224430f37 # Parent 902219a999018ffd728811ada56acd5f84dbfefb debuginstall: do not pass exception object to formatter (issue5676) diff -r 902219a99901 -r ada8a19672ab mercurial/debugcommands.py --- a/mercurial/debugcommands.py Thu Sep 07 22:27:23 2017 +0900 +++ b/mercurial/debugcommands.py Thu Sep 07 22:36:54 2017 +0900 @@ -1000,7 +1000,7 @@ 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 @@ ) 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 @@ 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 @@ 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 -r 902219a99901 -r ada8a19672ab tests/test-install.t --- a/tests/test-install.t Thu Sep 07 22:27:23 2017 +0900 +++ b/tests/test-install.t Thu Sep 07 22:36:54 2017 +0900 @@ -81,6 +81,14 @@ 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