Patchwork D2440: py3: hunt down str(exception) instances and use util.forcebytestr

login
register
mail settings
Submitter phabricator
Date Feb. 26, 2018, 5:43 a.m.
Message ID <c894c8ad99b2a0f764bed0b58e812925@localhost.localdomain>
Download mbox | patch
Permalink /patch/28374/
State Not Applicable
Headers show

Comments

phabricator - Feb. 26, 2018, 5:43 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG04c319a07c7b: py3: hunt down str(exception) instances and use util.forcebytestr (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2440?vs=6087&id=6096

REVISION DETAIL
  https://phab.mercurial-scm.org/D2440

AFFECTED FILES
  mercurial/commands.py
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/scmutil.py
  mercurial/ui.py
  mercurial/url.py
  mercurial/util.py

CHANGE DETAILS




To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -3634,7 +3634,7 @@ 
                 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 @@ 
                 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 {}
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -449,7 +449,7 @@ 
             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/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -366,7 +366,7 @@ 
         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/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -208,7 +208,7 @@ 
             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/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -259,7 +259,8 @@ 
                     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/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -2149,7 +2149,8 @@ 
                 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 @@ 
                 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/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3899,7 +3899,7 @@ 
         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: