py3: use util.forcevytestr to convert error to bytes
authorPulkit Goyal <7895pulkit@gmail.com>
Sat, 03 Mar 2018 21:01:07 +0530
changeset 36632 9e2866065982
parent 36631 8395fddde46c
child 36633 034a07e60e98
py3: use util.forcevytestr to convert error to bytes Differential Revision: https://phab.mercurial-scm.org/D2585
hgext/convert/subversion.py
hgext/mq.py
hgext/narrow/narrowbundle2.py
hgext/relink.py
--- a/hgext/convert/subversion.py	Sat Mar 03 09:50:07 2018 -0500
+++ b/hgext/convert/subversion.py	Sat Mar 03 21:01:07 2018 +0530
@@ -147,7 +147,7 @@
         # Caller may interrupt the iteration
         pickle.dump(None, fp, protocol)
     except Exception as inst:
-        pickle.dump(str(inst), fp, protocol)
+        pickle.dump(util.forcebytestr(inst), fp, protocol)
     else:
         pickle.dump(None, fp, protocol)
     fp.flush()
--- a/hgext/mq.py	Sat Mar 03 09:50:07 2018 -0500
+++ b/hgext/mq.py	Sat Mar 03 21:01:07 2018 +0530
@@ -723,7 +723,8 @@
         try:
             os.unlink(undo)
         except OSError as inst:
-            self.ui.warn(_('error removing undo: %s\n') % str(inst))
+            self.ui.warn(_('error removing undo: %s\n') %
+                         util.forcebytestr(inst))
 
     def backup(self, repo, files, copy=False):
         # backup local changes in --force case
--- a/hgext/narrow/narrowbundle2.py	Sat Mar 03 09:50:07 2018 -0500
+++ b/hgext/narrow/narrowbundle2.py	Sat Mar 03 21:01:07 2018 +0530
@@ -449,7 +449,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)))
 
     # Remove partial backup only if there were no exceptions
     vfs.unlink(chgrpfile)
--- a/hgext/relink.py	Sat Mar 03 09:50:07 2018 -0500
+++ b/hgext/relink.py	Sat Mar 03 21:01:07 2018 +0530
@@ -187,7 +187,7 @@
             relinked += 1
             savedbytes += sz
         except OSError as inst:
-            ui.warn('%s: %s\n' % (tgt, str(inst)))
+            ui.warn('%s: %s\n' % (tgt, util.forcebytestr(inst)))
 
     ui.progress(_('relinking'), None)