Mercurial > hg
comparison mercurial/i18n.py @ 38312:79dd61a4554f
py3: replace `unicode` with pycompat.unicode
unicode() is not available on Python 3 and throws a NameError because unicodes
are now default str() on py3.
Differential Revision: https://phab.mercurial-scm.org/D3708
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 13 Jun 2018 22:51:08 +0530 |
parents | 5bc7ff103081 |
children | dd83aafdb64a |
comparison
equal
deleted
inserted
replaced
38311:47f5454a30ed | 38312:79dd61a4554f |
---|---|
20 # modelled after templater.templatepath: | 20 # modelled after templater.templatepath: |
21 if getattr(sys, 'frozen', None) is not None: | 21 if getattr(sys, 'frozen', None) is not None: |
22 module = pycompat.sysexecutable | 22 module = pycompat.sysexecutable |
23 else: | 23 else: |
24 module = pycompat.fsencode(__file__) | 24 module = pycompat.fsencode(__file__) |
25 | |
26 try: | |
27 unicode | |
28 except NameError: | |
29 unicode = str | |
30 | 25 |
31 _languages = None | 26 _languages = None |
32 if (pycompat.iswindows | 27 if (pycompat.iswindows |
33 and 'LANGUAGE' not in encoding.environ | 28 and 'LANGUAGE' not in encoding.environ |
34 and 'LC_ALL' not in encoding.environ | 29 and 'LC_ALL' not in encoding.environ |
74 if message is None or not _ugettext: | 69 if message is None or not _ugettext: |
75 return message | 70 return message |
76 | 71 |
77 cache = _msgcache.setdefault(encoding.encoding, {}) | 72 cache = _msgcache.setdefault(encoding.encoding, {}) |
78 if message not in cache: | 73 if message not in cache: |
79 if type(message) is unicode: | 74 if type(message) is pycompat.unicode: |
80 # goofy unicode docstrings in test | 75 # goofy unicode docstrings in test |
81 paragraphs = message.split(u'\n\n') | 76 paragraphs = message.split(u'\n\n') |
82 else: | 77 else: |
83 paragraphs = [p.decode("ascii") for p in message.split('\n\n')] | 78 paragraphs = [p.decode("ascii") for p in message.split('\n\n')] |
84 # Be careful not to translate the empty string -- it holds the | 79 # Be careful not to translate the empty string -- it holds the |