Patchwork [5,of,7] py3: make posix.getuser return a bytes

login
register
mail settings
Submitter Pulkit Goyal
Date May 3, 2017, 9:59 a.m.
Message ID <4b5015610049afd91ae9.1493805564@pulkit-goyal>
Download mbox | patch
Permalink /patch/20400/
State Accepted
Headers show

Comments

Pulkit Goyal - May 3, 2017, 9:59 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1492716218 -19800
#      Fri Apr 21 00:53:38 2017 +0530
# Node ID 4b5015610049afd91ae99357657a6fad7c234547
# Parent  6740e4cde2638d1cfd56bf997c2aa7e741ac12bf
py3: make posix.getuser return a bytes
Yuya Nishihara - May 4, 2017, 2:13 a.m.
On Wed, 03 May 2017 15:29:24 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1492716218 -19800
> #      Fri Apr 21 00:53:38 2017 +0530
> # Node ID 4b5015610049afd91ae99357657a6fad7c234547
> # Parent  6740e4cde2638d1cfd56bf997c2aa7e741ac12bf
> py3: make posix.getuser return a bytes
> 
> diff -r 6740e4cde263 -r 4b5015610049 mercurial/posix.py
> --- a/mercurial/posix.py	Thu Apr 20 19:57:16 2017 +0530
> +++ b/mercurial/posix.py	Fri Apr 21 00:53:38 2017 +0530
> @@ -494,7 +494,7 @@
>  
>  def getuser():
>      '''return name of current user'''
> -    return getpass.getuser()
> +    return pycompat.fsencode(getpass.getuser())

Confirmed that they (ab)use filesystem encoding, so this is valid.

Patch

diff -r 6740e4cde263 -r 4b5015610049 mercurial/posix.py
--- a/mercurial/posix.py	Thu Apr 20 19:57:16 2017 +0530
+++ b/mercurial/posix.py	Fri Apr 21 00:53:38 2017 +0530
@@ -494,7 +494,7 @@ 
 
 def getuser():
     '''return name of current user'''
-    return getpass.getuser()
+    return pycompat.fsencode(getpass.getuser())
 
 def username(uid=None):
     """Return the name of the user with the given uid.