Mercurial > hg
changeset 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 | 47f5454a30ed |
children | 275cc461b854 |
files | hgext/convert/common.py hgext/convert/convcmd.py hgext/convert/darcs.py hgext/win32mbcs.py mercurial/i18n.py mercurial/pycompat.py mercurial/scmutil.py |
diffstat | 7 files changed, 8 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/common.py Fri Jun 15 02:07:39 2018 +0530 +++ b/hgext/convert/common.py Wed Jun 13 22:51:08 2018 +0530 @@ -214,7 +214,7 @@ if not encoding: encoding = self.encoding or 'utf-8' - if isinstance(s, unicode): + if isinstance(s, pycompat.unicode): return s.encode("utf-8") try: return s.decode(pycompat.sysstr(encoding)).encode("utf-8")
--- a/hgext/convert/convcmd.py Fri Jun 15 02:07:39 2018 +0530 +++ b/hgext/convert/convcmd.py Wed Jun 13 22:51:08 2018 +0530 @@ -55,7 +55,7 @@ orig_encoding = 'ascii' def recode(s): - if isinstance(s, unicode): + if isinstance(s, pycompat.unicode): return s.encode(pycompat.sysstr(orig_encoding), 'replace') else: return s.decode('utf-8').encode(
--- a/hgext/convert/darcs.py Fri Jun 15 02:07:39 2018 +0530 +++ b/hgext/convert/darcs.py Wed Jun 13 22:51:08 2018 +0530 @@ -104,7 +104,7 @@ shutil.rmtree(self.tmppath, ignore_errors=True) def recode(self, s, encoding=None): - if isinstance(s, unicode): + if isinstance(s, pycompat.unicode): # XMLParser returns unicode objects for anything it can't # encode into ASCII. We convert them back to str to get # recode's normal conversion behavior.
--- a/hgext/win32mbcs.py Fri Jun 15 02:07:39 2018 +0530 +++ b/hgext/win32mbcs.py Wed Jun 13 22:51:08 2018 +0530 @@ -90,7 +90,7 @@ return arg def encode(arg): - if isinstance(arg, unicode): + if isinstance(arg, pycompat.unicode): return arg.encode(_encoding) elif isinstance(arg, tuple): return tuple(map(encode, arg)) @@ -127,7 +127,7 @@ " %s encoding\n") % (_encoding)) def wrapper(func, args, kwds): - return basewrapper(func, unicode, encode, decode, args, kwds) + return basewrapper(func, pycompat.unicode, encode, decode, args, kwds) def reversewrapper(func, args, kwds):
--- a/mercurial/i18n.py Fri Jun 15 02:07:39 2018 +0530 +++ b/mercurial/i18n.py Wed Jun 13 22:51:08 2018 +0530 @@ -23,11 +23,6 @@ else: module = pycompat.fsencode(__file__) -try: - unicode -except NameError: - unicode = str - _languages = None if (pycompat.iswindows and 'LANGUAGE' not in encoding.environ @@ -76,7 +71,7 @@ cache = _msgcache.setdefault(encoding.encoding, {}) if message not in cache: - if type(message) is unicode: + if type(message) is pycompat.unicode: # goofy unicode docstrings in test paragraphs = message.split(u'\n\n') else:
--- a/mercurial/pycompat.py Fri Jun 15 02:07:39 2018 +0530 +++ b/mercurial/pycompat.py Wed Jun 13 22:51:08 2018 +0530 @@ -302,6 +302,7 @@ else: import cStringIO + unicode = unicode bytechr = chr byterepr = repr bytestr = str
--- a/mercurial/scmutil.py Fri Jun 15 02:07:39 2018 +0530 +++ b/mercurial/scmutil.py Wed Jun 13 22:51:08 2018 +0530 @@ -233,7 +233,7 @@ except (AttributeError, IndexError): # it might be anything, for example a string reason = inst.reason - if isinstance(reason, unicode): + if isinstance(reason, pycompat.unicode): # SSLError of Python 2.7.9 contains a unicode reason = encoding.unitolocal(reason) ui.warn(_("abort: error: %s\n") % reason)