diff mercurial/i18n.py @ 30050:d229be12e256

py3: convert to unicode to pass into encode() encoding.encoding is bytes, we need to pass it to encode() which accepts unicodes in py3, so used pycomapt.sysstr() Also this can't be done using transformer as that only transforms the string values not variables.
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 07 Oct 2016 12:13:28 +0200
parents 02328b5d775d
children 2bde971474d2
line wrap: on
line diff
--- a/mercurial/i18n.py	Sat Oct 01 09:55:32 2016 +0800
+++ b/mercurial/i18n.py	Fri Oct 07 12:13:28 2016 +0200
@@ -12,7 +12,10 @@
 import os
 import sys
 
-from . import encoding
+from . import (
+    encoding,
+    pycompat,
+)
 
 # modelled after templater.templatepath:
 if getattr(sys, 'frozen', None) is not None:
@@ -85,7 +88,8 @@
             # means u.encode(sys.getdefaultencoding()).decode(enc). Since
             # the Python encoding defaults to 'ascii', this fails if the
             # translated string use non-ASCII characters.
-            _msgcache[message] = u.encode(encoding.encoding, "replace")
+            encodingstr = pycompat.sysstr(encoding.encoding)
+            _msgcache[message] = u.encode(encodingstr, "replace")
         except LookupError:
             # An unknown encoding results in a LookupError.
             _msgcache[message] = message