Patchwork [5,of,6,py3] dispatch: cope with sys.version being unicode on Python 3

login
register
mail settings
Submitter Augie Fackler
Date March 6, 2017, 11:23 p.m.
Message ID <c28e0b997db472d02869.1488842589@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/18949/
State Accepted
Headers show

Comments

Augie Fackler - March 6, 2017, 11:23 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1488565790 18000
#      Fri Mar 03 13:29:50 2017 -0500
# Node ID c28e0b997db472d0286927234bf06cc9848b6ff7
# Parent  00547c2e1a71fc5d3efd13e5c766fda8bc398e6a
dispatch: cope with sys.version being unicode on Python 3

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -893,7 +893,12 @@  def _exceptionwarning(ui):
             bugtracker = _("https://mercurial-scm.org/wiki/BugTracker")
         warning = (_("** unknown exception encountered, "
                      "please report by visiting\n** ") + bugtracker + '\n')
-    warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) +
+    if pycompat.ispy3:
+        sysversion = sys.version.encode(u'utf-8')
+    else:
+        sysversion = sys.version
+    sysversion = sysversion.replace('\n', '')
+    warning += ((_("** Python %s\n") % sysversion) +
                 (_("** Mercurial Distributed SCM (version %s)\n") %
                  util.version()) +
                 (_("** Extensions loaded: %s\n") %