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

Authored by pulkit on Jun 9 2018, 1:37 PM.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
pulkit created this revision.Jun 9 2018, 1:37 PM
yuja added a subscriber: yuja.Jun 9 2018, 10:18 PM

@@ -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)

Nit: could be b'%d' %.

This revision was automatically updated to reflect the committed changes.
In D3706#58203, @yuja wrote:

@@ -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)

Nit: could be b'%d' %.

I was afraid that someone can pass uid as a str or bytes. I will followup with the suggestion.