# HG changeset patch # User Augie Fackler # Date 2018-02-26 04:08:41 # Node ID 04c319a07c7b8d152e4bd00dd42d887cca24488a # Parent 1df7e7b8558e34440cd9f1bf6eb691260869fd40 py3: hunt down str(exception) instances and use util.forcebytestr I decided to grep around for \sstr\( and see what low-hanging fruit that showed me. This was part of that hunt. That grep pattern still has some things worth exploring. Differential Revision: https://phab.mercurial-scm.org/D2440 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3899,7 +3899,7 @@ def postincoming(ui, repo, modheads, opt try: return hg.updatetotally(ui, repo, checkout, brev) except error.UpdateAbort as inst: - msg = _("not updating: %s") % str(inst) + msg = _("not updating: %s") % util.forcebytestr(inst) hint = inst.hint raise error.UpdateAbort(msg, hint=hint) if modheads > 1: diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -2149,7 +2149,8 @@ def filterclonebundleentries(repo, entri continue except error.UnsupportedBundleSpecification as e: repo.ui.debug('filtering %s because unsupported bundle ' - 'spec: %s\n' % (entry['URL'], str(e))) + 'spec: %s\n' % ( + entry['URL'], util.forcebytestr(e))) continue # If we don't have a spec and requested a stream clone, we don't know # what the entry is so don't attempt to apply it. @@ -2254,7 +2255,8 @@ def trypullbundlefromurl(ui, repo, url): bundle2.applybundle(repo, cg, tr, 'clonebundles', url) return True except urlerr.httperror as e: - ui.warn(_('HTTP error fetching bundle: %s\n') % str(e)) + ui.warn(_('HTTP error fetching bundle: %s\n') % + util.forcebytestr(e)) except urlerr.urlerror as e: ui.warn(_('error fetching bundle: %s\n') % e.reason) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -259,7 +259,8 @@ class localpeer(repository.peer): bundle2.processbundle(self._repo, b) raise except error.PushRaced as exc: - raise error.ResponseError(_('push failed:'), str(exc)) + raise error.ResponseError(_('push failed:'), + util.forcebytestr(exc)) # End of _basewirecommands interface. diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -208,7 +208,7 @@ def callcatch(ui, func): ui.warn(_("(%s)\n") % inst.hint) except ImportError as inst: ui.warn(_("abort: %s!\n") % inst) - m = str(inst).split()[-1] + m = util.forcebytestr(inst).split()[-1] if m in "mpatch bdiff".split(): ui.warn(_("(did you forget to compile extensions?)\n")) elif m in "zlib".split(): diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -366,7 +366,7 @@ class ui(object): except error.ConfigError as inst: if trusted: raise - self.warn(_("ignored: %s\n") % str(inst)) + self.warn(_("ignored: %s\n") % util.forcebytestr(inst)) if self.plain(): for k in ('debug', 'fallbackencoding', 'quiet', 'slash', diff --git a/mercurial/url.py b/mercurial/url.py --- a/mercurial/url.py +++ b/mercurial/url.py @@ -449,7 +449,7 @@ class cookiehandler(urlreq.basehandler): self.cookiejar = cookiejar except util.cookielib.LoadError as e: ui.warn(_('(error loading cookie file %s: %s; continuing without ' - 'cookies)\n') % (cookiefile, str(e))) + 'cookies)\n') % (cookiefile, util.forcebytestr(e))) def http_request(self, request): if self.cookiejar: diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -3634,7 +3634,7 @@ class _zlibengine(compressionengine): return zlib.decompress(data) except zlib.error as e: raise error.RevlogError(_('revlog decompress error: %s') % - str(e)) + forcebytestr(e)) def revlogcompressor(self, opts=None): return self.zlibrevlogcompressor() @@ -3860,7 +3860,7 @@ class _zstdengine(compressionengine): return ''.join(chunks) except Exception as e: raise error.RevlogError(_('revlog decompress error: %s') % - str(e)) + forcebytestr(e)) def revlogcompressor(self, opts=None): opts = opts or {}