diff -r 57b0c7221dba -r 3ea3c96ada54 mercurial/templatekw.py --- a/mercurial/templatekw.py Sun Apr 22 11:38:53 2018 +0900 +++ b/mercurial/templatekw.py Sun Apr 23 13:15:30 2017 +0900 @@ -278,6 +278,8 @@ if isinstance(s, encoding.localstr): # try hard to preserve utf-8 bytes return encoding.tolocal(encoding.fromlocal(s).strip()) + elif isinstance(s, encoding.safelocalstr): + return encoding.safelocalstr(s.strip()) else: return s.strip()