Patchwork D2649: py3: use util.forcebytestr instead of str to convert error messages

login
register
mail settings
Submitter phabricator
Date March 4, 2018, 5:28 p.m.
Message ID <differential-rev-PHID-DREV-mqekbdbkifbcuzycqwln-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28938/
State Superseded
Headers show

Comments

phabricator - March 4, 2018, 5:28 p.m.
pulkit created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hg.py
  mercurial/repair.py
  mercurial/revlog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1996,7 +1996,8 @@ 
             try:
                 return _zlibdecompress(data)
             except zlib.error as e:
-                raise RevlogError(_('revlog decompress error: %s') % str(e))
+                raise RevlogError(_('revlog decompress error: %s') %
+                                  util.forcebytestr(e))
         # '\0' is more common than 'u' so it goes first.
         elif t == '\0':
             return data
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -235,7 +235,7 @@ 
             except OSError as e:
                 if e.errno != errno.ENOENT:
                     ui.warn(_('error removing %s: %s\n') %
-                            (undovfs.join(undofile), str(e)))
+                            (undovfs.join(undofile), util.forcebytestr(e)))
 
     except: # re-raises
         if backupfile:
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -269,7 +269,7 @@ 
             # ValueError is raised on Windows if the drive letters differ on
             # each path
             raise error.Abort(_('cannot calculate relative path'),
-                              hint=str(e))
+                              hint=util.forcebytestr(e))
     else:
         requirements += 'shared\n'