Patchwork [1,of,2] py3: stringify IOError/OSError without loosing local character

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 14, 2018, 12:56 p.m.
Message ID <bc9daf3da6a6e5333199.1518613012@mimosa>
Download mbox | patch
Permalink /patch/27908/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 14, 2018, 12:56 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1518611367 -32400
#      Wed Feb 14 21:29:27 2018 +0900
# Node ID bc9daf3da6a6e53331997ea2145a85fd85417e77
# Parent  be50b344a4b74614c8979ec3b327183c0336b7b1
py3: stringify IOError/OSError without loosing local character

Follows up fa4d333cac58. An environment error may contain non-ascii characters
on Windows, which should be encoded to a platform-native string.

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -377,7 +377,7 @@  class revbranchcache(object):
                 self._rbcrevs[:] = data
             except (IOError, OSError) as inst:
                 repo.ui.debug("couldn't read revision branch cache: %s\n" %
-                              pycompat.bytestr(inst))
+                              util.forcebytestr(inst))
         # remember number of good records on disk
         self._rbcrevslen = min(len(self._rbcrevs) // _rbcrecsize,
                                len(repo.changelog))