changeset 36500:43e108027b0d

py3: move between bytes and unicode when re-raising IOError IOError is a Python exception, which argument must be a system string.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 01 Mar 2018 06:47:06 -0500
parents 77f681f11003
children 169ac2bb3c9c
files mercurial/templater.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templater.py	Thu Mar 01 06:43:13 2018 -0500
+++ b/mercurial/templater.py	Thu Mar 01 06:47:06 2018 -0500
@@ -1537,8 +1537,9 @@
                 raise TemplateNotFound(_('"%s" not in template map') %
                                        inst.args[0])
             except IOError as inst:
-                raise IOError(inst.args[0], _('template file %s: %s') %
-                              (self.map[t][1], inst.args[1]))
+                reason = (_('template file %s: %s')
+                          % (self.map[t][1], util.forcebytestr(inst.args[1])))
+                raise IOError(inst.args[0], encoding.strfromlocal(reason))
         return self.cache[t]
 
     def render(self, mapping):