From patchwork Thu Mar 1 14:17:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,8] py3: move between bytes and unicode when re-raising IOError From: Yuya Nishihara X-Patchwork-Id: 28551 Message-Id: <63188d7c6282a6851842.1519913831@mimosa> To: mercurial-devel@mercurial-scm.org Date: Thu, 01 Mar 2018 09:17:11 -0500 # HG changeset patch # User Yuya Nishihara # Date 1519904826 18000 # Thu Mar 01 06:47:06 2018 -0500 # Node ID 63188d7c6282a68518421ef7f60c85b312ffec3b # Parent 7002f11e42c57d80e3e001b48e956d0f9a94b758 py3: move between bytes and unicode when re-raising IOError IOError is a Python exception, which argument must be a system string. diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -1537,8 +1537,9 @@ class templater(object): 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):