unicode: consistently use 'utf-8' everywhere

Summary:
We generally use 'utf-8' but are using 'utf8' at some places. This
diff changes to using 'utf-8' consistently everywhere.

Reviewed By: farnz

Differential Revision: D19674111

fbshipit-source-id: 3be42859a180ded1c234b805259f086f9531ba18
This commit is contained in:
Saurabh Singh 2020-01-31 17:32:59 -08:00 committed by Facebook Github Bot
parent 57d59e5499
commit 1891591abc
6 changed files with 9 additions and 9 deletions

View File

@ -109,7 +109,7 @@ class SvnRaTransport(object):
raise
else:
self.ra = ra
svn.ra.reparent(self.ra, self.svn_url.encode("utf8"))
svn.ra.reparent(self.ra, self.svn_url.encode("utf-8"))
class Reporter(object):
def __init__(self, reporter_data):

View File

@ -22,7 +22,7 @@ class PhabricatorClientError(Exception):
class PhabricatorGraphQLClientRequests(object):
def sendpost(self, request_url, data, timeout, ca_bundle):
res = requests.post(request_url, data, verify=ca_bundle or True)
data = json.loads(res.content.decode("utf8"))
data = json.loads(res.content.decode("utf-8"))
if res.status_code != 200:
raise PhabricatorClientError(
"Phabricator not available returned " + str(res.status), res

View File

@ -365,7 +365,7 @@ if pycompat.iswindows:
if result <= numwchars:
path = buf.value[4:].replace("\\", "/")
if compat.PYTHON2:
path = path.encode("utf8")
path = path.encode("utf-8")
return path
# Not big enough; the result is the amount we need

View File

@ -1370,7 +1370,7 @@ def truncatelonglines(context, mapping, args):
suffix = evalstring(context, mapping, args[2])
if isinstance(suffix, bytes):
# Python 2
truncatedwidth -= len(suffix.decode("utf8"))
truncatedwidth -= len(suffix.decode("utf-8"))
else:
# Python 3
truncatedwidth -= len(suffix)

View File

@ -45,13 +45,13 @@ if len(sys.argv) > 2:
env = [(k, v) for k, v in os.environ.items() if k.startswith("HG_") and v]
env.sort()
out.write(b"%s hook: " % name.encode("utf8"))
out.write(b"%s hook: " % name.encode("utf-8"))
if os.name == "nt":
filter = lambda x: x.replace("\\", "/")
else:
filter = lambda x: x
vars = ["%s=%s" % (k, filter(v)) for k, v in env]
out.write(" ".join(vars).encode("utf8"))
out.write(" ".join(vars).encode("utf-8"))
out.write(b"\n")
out.close()

View File

@ -635,7 +635,7 @@ def parseargs(args, parser):
if options.with_hg:
options.with_hg = canonpath(_bytespath(options.with_hg))
# HGEXECUTABLEPATH is used by util.hgcmd()
os.environ["HGEXECUTABLEPATH"] = options.with_hg.decode("utf8")
os.environ["HGEXECUTABLEPATH"] = options.with_hg.decode("utf-8")
if not (
os.path.isfile(options.with_hg) and os.access(options.with_hg, os.X_OK)
):
@ -1255,7 +1255,7 @@ class Test(unittest.TestCase):
env = self._getenv()
self._genrestoreenv(env)
self._daemonpids.append(env["DAEMON_PIDS"])
self._createhgrc(env["HGRCPATH"].rsplit(os.pathsep.encode("utf8"), 1)[-1])
self._createhgrc(env["HGRCPATH"].rsplit(os.pathsep.encode("utf-8"), 1)[-1])
vlog("# Test", self.name)
vlog("# chg in use: %s" % self._usechg)
@ -1477,7 +1477,7 @@ class Test(unittest.TestCase):
defineport(port)
rcpath = os.path.join(self._threadtmp, b".hgrc")
rcpaths = [p.encode("utf-8") for p in self._extrarcpaths] + [rcpath]
env["HGRCPATH"] = os.pathsep.encode("utf8").join(rcpaths)
env["HGRCPATH"] = os.pathsep.encode("utf-8").join(rcpaths)
env["DAEMON_PIDS"] = os.path.join(self._threadtmp, b"daemon.pids")
env["HGEDITOR"] = (
'"' + PYTHON.decode("utf-8") + '"' + ' -c "import sys; sys.exit(0)"'