Patchwork D3125: py3: convert user value to bytes using pycompat.fsencode()

login
register
mail settings
Submitter phabricator
Date April 5, 2018, 12:31 p.m.
Message ID <differential-rev-PHID-DREV-f7qioxkuolol5ty2xptj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30352/
State Superseded
Headers show

Comments

phabricator - April 5, 2018, 12:31 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  procutil.getuser() can return unicode values. Let's convert them to bytes.
  
  This makes test-journal* pass on Python 3.5.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/journal.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - April 5, 2018, 1:45 p.m.
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  Unicode issue is handled by posix.py. The problem is `mockgetuser()`
  returns a unicode string.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel
phabricator - April 5, 2018, 7:23 p.m.
pulkit added a comment.


  In https://phab.mercurial-scm.org/D3125#50284, @yuja wrote:
  
  > Unicode issue is handled by posix.py. The problem is `mockgetuser()`
  >  returns a unicode string.
  
  
  Thanks, I overlooked that and was unable to find what can cause trouble so just added an extra fsencode() call.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/hgext/journal.py b/hgext/journal.py
--- a/hgext/journal.py
+++ b/hgext/journal.py
@@ -256,7 +256,7 @@ 
     _lockref = None
 
     def __init__(self, repo):
-        self.user = procutil.getuser()
+        self.user = pycompat.fsencode(procutil.getuser())
         self.ui = repo.ui
         self.vfs = repo.vfs