# HG changeset patch # User Yuya Nishihara # Date 1517026446 -32400 # Node ID d5457d94e1c93596251660e9647d804e223ef48e # Parent a2b3b5c5a25ae194346bd9c18b194d564683e11e py3: replace "if ispy3" by pycompat.sysbytes() or util.forcebytestr() diff -r a2b3b5c5a25a -r d5457d94e1c9 mercurial/dispatch.py --- a/mercurial/dispatch.py Sat Jan 27 13:11:46 2018 +0900 +++ b/mercurial/dispatch.py Sat Jan 27 13:14:06 2018 +0900 @@ -939,9 +939,9 @@ worst = None, ct, '' if ui.config('ui', 'supportcontact') is None: for name, mod in extensions.extensions(): - testedwith = getattr(mod, 'testedwith', '') - if pycompat.ispy3 and isinstance(testedwith, str): - testedwith = testedwith.encode(u'utf-8') + # 'testedwith' should be bytes, but not all extensions are ported + # to py3 and we don't want UnicodeException because of that. + testedwith = util.forcebytestr(getattr(mod, 'testedwith', '')) report = getattr(mod, 'buglink', _('the extension author.')) if not testedwith.strip(): # We found an untested extension. It's likely the culprit. @@ -976,11 +976,7 @@ bugtracker = _("https://mercurial-scm.org/wiki/BugTracker") warning = (_("** unknown exception encountered, " "please report by visiting\n** ") + bugtracker + '\n') - if pycompat.ispy3: - sysversion = sys.version.encode(u'utf-8') - else: - sysversion = sys.version - sysversion = sysversion.replace('\n', '') + sysversion = pycompat.sysbytes(sys.version).replace('\n', '') warning += ((_("** Python %s\n") % sysversion) + (_("** Mercurial Distributed SCM (version %s)\n") % util.version()) +