py3: use util.forcebytestr instead of str to convert error messages
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 04 Mar 2018 22:37:41 +0530
changeset 36725 f659a407e5ee
parent 36724 d77c3b023393
child 36726 7dc1a21d57cc
py3: use util.forcebytestr instead of str to convert error messages Differential Revision: https://phab.mercurial-scm.org/D2649
mercurial/hg.py
mercurial/repair.py
mercurial/revlog.py
--- a/mercurial/hg.py	Sat Mar 03 23:49:39 2018 -0500
+++ b/mercurial/hg.py	Sun Mar 04 22:37:41 2018 +0530
@@ -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'
 
--- a/mercurial/repair.py	Sat Mar 03 23:49:39 2018 -0500
+++ b/mercurial/repair.py	Sun Mar 04 22:37:41 2018 +0530
@@ -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:
--- a/mercurial/revlog.py	Sat Mar 03 23:49:39 2018 -0500
+++ b/mercurial/revlog.py	Sun Mar 04 22:37:41 2018 +0530
@@ -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