Patchwork D3708: py3: replace `unicode` with pycompat.unicode

login
register
mail settings
Submitter phabricator
Date June 15, 2018, 12:48 p.m.
Message ID <47ef696b37c32586974cc1e93b71cdbf@localhost.localdomain>
Download mbox | patch
Permalink /patch/32162/
State Not Applicable
Headers show

Comments

phabricator - June 15, 2018, 12:48 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG79dd61a4554f: py3: replace `unicode` with pycompat.unicode (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3708?vs=9053&id=9079

REVISION DETAIL
  https://phab.mercurial-scm.org/D3708

AFFECTED 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

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -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)
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -302,6 +302,7 @@ 
 else:
     import cStringIO
 
+    unicode = unicode
     bytechr = chr
     byterepr = repr
     bytestr = str
diff --git a/mercurial/i18n.py b/mercurial/i18n.py
--- a/mercurial/i18n.py
+++ b/mercurial/i18n.py
@@ -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:
diff --git a/hgext/win32mbcs.py b/hgext/win32mbcs.py
--- a/hgext/win32mbcs.py
+++ b/hgext/win32mbcs.py
@@ -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):
diff --git a/hgext/convert/darcs.py b/hgext/convert/darcs.py
--- a/hgext/convert/darcs.py
+++ b/hgext/convert/darcs.py
@@ -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.
diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -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(
diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -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")