changeset 30330:a2f2f694dce9

py3: have bytes version of sys.argv sys.argv returns unicodes on Python 3. We need a bytes version for us. There was also a python bug/feature request which wanted then to implement one. They rejected and it is quoted in one of the comments that we can use fsencode() to get a bytes version of sys.argv. Though not sure about its correctness. Link to the comment: http://bugs.python.org/issue8776#msg217416 After this patch we will have pycompat.sysargv which will return us bytes version of sys.argv. If this patch goes in, i will like to make transformer rewrite sys.argv with pycompat.argv because there are lot of occurences.
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 06 Nov 2016 04:36:26 +0530
parents dadb00a0ec0f
children b19291e5d506
files mercurial/pycompat.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pycompat.py	Sun Oct 09 09:00:47 2016 -0400
+++ b/mercurial/pycompat.py	Sun Nov 06 04:36:26 2016 +0530
@@ -43,6 +43,7 @@
     osname = os.name.encode('ascii')
     ospathsep = os.pathsep.encode('ascii')
     ossep = os.sep.encode('ascii')
+    sysargv = list(map(os.fsencode, sys.argv))
 
     def sysstr(s):
         """Return a keyword str to be passed to Python functions such as
@@ -91,6 +92,7 @@
     osname = os.name
     ospathsep = os.pathsep
     ossep = os.sep
+    sysargv = sys.argv
 
 stringio = io.StringIO
 empty = _queue.Empty