Mercurial > public > mercurial-scm > hg
comparison mercurial/pycompat.py @ 30668:3fcaf0f660ce
py3: have bytes version of sys.executable
sys.executable on Python 3 returns unicodes and we want bytes. So this patch
adds a new pycompat.sysexecutable which returns bytes by encoding using
os.fsencode() since it is path variable.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Tue, 20 Dec 2016 00:02:24 +0530 |
parents | bb0d5aad761a |
children | caf7e1c5efe4 |
comparison
equal
deleted
inserted
replaced
30667:5861bdbeb9a3 | 30668:3fcaf0f660ce |
---|---|
50 osaltsep = osaltsep.encode('ascii') | 50 osaltsep = osaltsep.encode('ascii') |
51 # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which | 51 # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which |
52 # returns bytes. | 52 # returns bytes. |
53 getcwd = os.getcwdb | 53 getcwd = os.getcwdb |
54 sysplatform = sys.platform.encode('ascii') | 54 sysplatform = sys.platform.encode('ascii') |
55 sysexecutable = sys.executable | |
56 if sysexecutable: | |
57 sysexecutable = os.fsencode(sysexecutable) | |
55 | 58 |
56 # TODO: .buffer might not exist if std streams were replaced; we'll need | 59 # TODO: .buffer might not exist if std streams were replaced; we'll need |
57 # a silly wrapper to make a bytes stream backed by a unicode one. | 60 # a silly wrapper to make a bytes stream backed by a unicode one. |
58 stdin = sys.stdin.buffer | 61 stdin = sys.stdin.buffer |
59 stdout = sys.stdout.buffer | 62 stdout = sys.stdout.buffer |
156 stderr = sys.stderr | 159 stderr = sys.stderr |
157 sysargv = sys.argv | 160 sysargv = sys.argv |
158 sysplatform = sys.platform | 161 sysplatform = sys.platform |
159 getcwd = os.getcwd | 162 getcwd = os.getcwd |
160 osgetenv = os.getenv | 163 osgetenv = os.getenv |
164 sysexecutable = sys.executable | |
161 | 165 |
162 stringio = io.StringIO | 166 stringio = io.StringIO |
163 empty = _queue.Empty | 167 empty = _queue.Empty |
164 queue = _queue.Queue | 168 queue = _queue.Queue |
165 | 169 |