Patchwork [5,of,8] py3: convert to unicode to pass to gettext.translation

login
register
mail settings
Submitter Pulkit Goyal
Date Nov. 5, 2016, 11:16 p.m.
Message ID <0c892b7a70b56a27d485.1478387782@pulkit-goyal>
Download mbox | patch
Permalink /patch/17357/
State Accepted
Headers show

Comments

Pulkit Goyal - Nov. 5, 2016, 11:16 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1478384854 -19800
#      Sun Nov 06 03:57:34 2016 +0530
# Node ID 0c892b7a70b56a27d485562b4191eb44da625f5b
# Parent  95b462cda94a4cf9c399a3f3bae348923855542d
py3: convert to unicode to pass to gettext.translation

In one of the previous patch, we converted util.datapath as bytes. In this
case we have to pass bytes to gettext.translation otherwise it will cry. Used
pycompat.fsdecode() to decode it back to unicode as it was converted to bytes
using pycompat.fsencode()

Patch

diff -r 95b462cda94a -r 0c892b7a70b5 mercurial/i18n.py
--- a/mercurial/i18n.py	Sun Nov 06 03:44:44 2016 +0530
+++ b/mercurial/i18n.py	Sun Nov 06 03:57:34 2016 +0530
@@ -49,6 +49,7 @@ 
 _ugettext = None
 
 def setdatapath(datapath):
+    datapath = pycompat.fsdecode(datapath)
     localedir = os.path.join(datapath, pycompat.sysstr('locale'))
     t = gettextmod.translation('hg', localedir, _languages, fallback=True)
     global _ugettext