py3: make sure util.username() always returns bytes
authorPulkit Goyal <7895pulkit@gmail.com>
Sat, 09 Jun 2018 15:14:31 +0530
changeset 38252 a4aa77b84efd
parent 38251 47b9240615ca
child 38253 1b121cc680f2
py3: make sure util.username() always returns bytes Differential Revision: https://phab.mercurial-scm.org/D3706
mercurial/posix.py
--- a/mercurial/posix.py	Sat Jun 09 15:01:04 2018 +0530
+++ b/mercurial/posix.py	Sat Jun 09 15:14:31 2018 +0530
@@ -541,9 +541,9 @@
     if uid is None:
         uid = os.getuid()
     try:
-        return pwd.getpwuid(uid)[0]
+        return pycompat.fsencode(pwd.getpwuid(uid)[0])
     except KeyError:
-        return str(uid)
+        return b'%d' % uid
 
 def groupname(gid=None):
     """Return the name of the group with the given gid.