Patchwork D3706: py3: make sure util.username() always returns bytes

login
register
mail settings
Submitter phabricator
Date June 10, 2018, 2:20 a.m.
Message ID <9a9ebfb905f79fcab60f0512da4357a6@localhost.localdomain>
Download mbox | patch
Permalink /patch/32043/
State Not Applicable
Headers show

Comments

phabricator - June 10, 2018, 2:20 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb4269bbbefbc: py3: make sure util.username() always returns bytes (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3706?vs=9003&id=9005

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

AFFECTED FILES
  mercurial/posix.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -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 pycompat.bytestr(uid)
 
 def groupname(gid=None):
     """Return the name of the group with the given gid.