diff --git a/hgext/convert/common.py b/hgext/convert/common.py --- a/hgext/convert/common.py +++ b/hgext/convert/common.py @@ -246,7 +246,7 @@ class converter_source(object): if not encoding: encoding = self.encoding or b'utf-8' - if isinstance(s, pycompat.unicode): + if isinstance(s, str): return s.encode("utf-8") try: return s.decode(pycompat.sysstr(encoding)).encode("utf-8") diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py --- a/hgext/convert/convcmd.py +++ b/hgext/convert/convcmd.py @@ -86,7 +86,7 @@ def readauthormap(ui, authorfile, author def recode(s): - if isinstance(s, pycompat.unicode): + if isinstance(s, str): return s.encode(pycompat.sysstr(orig_encoding), 'replace') else: return s.decode('utf-8').encode( diff --git a/hgext/convert/darcs.py b/hgext/convert/darcs.py --- a/hgext/convert/darcs.py +++ b/hgext/convert/darcs.py @@ -113,7 +113,7 @@ class darcs_source(common.converter_sour shutil.rmtree(self.tmppath, ignore_errors=True) def recode(self, s, encoding=None): - if isinstance(s, pycompat.unicode): + if isinstance(s, str): # 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/lfs/blobstore.py b/hgext/lfs/blobstore.py --- a/hgext/lfs/blobstore.py +++ b/hgext/lfs/blobstore.py @@ -273,7 +273,7 @@ def _urlerrorreason(urlerror): except (AttributeError, IndexError): # it might be anything, for example a string reason = inst.reason - if isinstance(reason, pycompat.unicode): + if isinstance(reason, str): # SSLError of Python 2.7.9 contains a unicode reason = encoding.unitolocal(reason) return reason @@ -406,7 +406,7 @@ class _gitlfsremote(object): ) def encodestr(x): - if isinstance(x, pycompat.unicode): + if isinstance(x, str): return x.encode('utf-8') return x diff --git a/hgext/phabricator.py b/hgext/phabricator.py --- a/hgext/phabricator.py +++ b/hgext/phabricator.py @@ -219,9 +219,7 @@ def _loadhgrc(orig, ui, wdirvfs, hgvfs, rawparams = encoding.unifromlocal(wdirvfs.read(b".arcconfig")) # json.loads only returns unicode strings arcconfig = pycompat.rapply( - lambda x: encoding.unitolocal(x) - if isinstance(x, pycompat.unicode) - else x, + lambda x: encoding.unitolocal(x) if isinstance(x, str) else x, pycompat.json_loads(rawparams), ) @@ -447,9 +445,7 @@ def callconduit(ui, name, params): time.sleep(retry_interval) ui.debug(b'Conduit Response: %s\n' % body) parsed = pycompat.rapply( - lambda x: encoding.unitolocal(x) - if isinstance(x, pycompat.unicode) - else x, + lambda x: encoding.unitolocal(x) if isinstance(x, str) else x, # json.loads only accepts bytes from py3.6+ pycompat.json_loads(encoding.unifromlocal(body)), ) @@ -473,9 +469,7 @@ def debugcallconduit(ui, repo, name): rawparams = encoding.unifromlocal(ui.fin.read()) # json.loads only returns unicode strings params = pycompat.rapply( - lambda x: encoding.unitolocal(x) - if isinstance(x, pycompat.unicode) - else x, + lambda x: encoding.unitolocal(x) if isinstance(x, str) else x, pycompat.json_loads(rawparams), ) # json.dumps only accepts unicode strings diff --git a/hgext/win32mbcs.py b/hgext/win32mbcs.py --- a/hgext/win32mbcs.py +++ b/hgext/win32mbcs.py @@ -94,7 +94,7 @@ def decode(arg): def encode(arg): - if isinstance(arg, pycompat.unicode): + if isinstance(arg, str): return arg.encode(_encoding) elif isinstance(arg, tuple): return tuple(map(encode, arg)) @@ -135,7 +135,7 @@ def basewrapper(func, argtype, enc, dec, def wrapper(func, args, kwds): - return basewrapper(func, pycompat.unicode, encode, decode, args, kwds) + return basewrapper(func, str, encode, decode, args, kwds) def reversewrapper(func, args, kwds): diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py --- a/mercurial/hgweb/__init__.py +++ b/mercurial/hgweb/__init__.py @@ -36,7 +36,7 @@ def hgweb(config, name=None, baseui=None - list of virtual:real tuples (multi-repo view) """ - if isinstance(config, pycompat.unicode): + if isinstance(config, str): raise error.ProgrammingError( b'Mercurial only supports encoded strings: %r' % config ) diff --git a/mercurial/i18n.py b/mercurial/i18n.py --- a/mercurial/i18n.py +++ b/mercurial/i18n.py @@ -85,9 +85,9 @@ def gettext(message): cache = _msgcache.setdefault(encoding.encoding, {}) if message not in cache: - if type(message) is pycompat.unicode: + if type(message) is str: # goofy unicode docstrings in test - paragraphs = message.split(u'\n\n') # type: List[pycompat.unicode] + paragraphs = message.split(u'\n\n') # type: List[str] else: # should be ascii, but we have unicode docstrings in test, which # are converted to utf-8 bytes on Python 3. diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -227,7 +227,7 @@ def callcatch(ui, func): except (AttributeError, IndexError): # it might be anything, for example a string reason = inst.reason - if isinstance(reason, pycompat.unicode): + if isinstance(reason, str): # SSLError of Python 2.7.9 contains a unicode reason = encoding.unitolocal(reason) ui.error(_(b"abort: error: %s\n") % stringutil.forcebytestr(reason)) diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -372,9 +372,7 @@ def obfuscate(text): """Any text. Returns the input text rendered as a sequence of XML entities. """ - text = pycompat.unicode( - text, pycompat.sysstr(encoding.encoding), r'replace' - ) + text = str(text, pycompat.sysstr(encoding.encoding), r'replace') return b''.join([b'&#%d;' % ord(c) for c in text])