comparison mercurial/pycompat.py @ 30820:6a70cf94d1b5

py3: replace pycompat.getenv with encoding.environ.get pycompat.getenv returns os.getenvb on py3 which is not available on Windows. This patch replaces them with encoding.environ.get and checks to ensure no new instances of os.getenv or os.setenv are introduced.
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 15 Jan 2017 13:17:05 +0530
parents caf7e1c5efe4
children 86cd1f2cfff5 76a64c1e5439
comparison
equal deleted inserted replaced
30819:897726622877 30820:6a70cf94d1b5
44 # A bytes version of os.name. 44 # A bytes version of os.name.
45 osname = os.name.encode('ascii') 45 osname = os.name.encode('ascii')
46 ospathsep = os.pathsep.encode('ascii') 46 ospathsep = os.pathsep.encode('ascii')
47 ossep = os.sep.encode('ascii') 47 ossep = os.sep.encode('ascii')
48 osaltsep = os.altsep 48 osaltsep = os.altsep
49 osgetenv = os.getenvb
50 if osaltsep: 49 if osaltsep:
51 osaltsep = osaltsep.encode('ascii') 50 osaltsep = osaltsep.encode('ascii')
52 # 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
53 # returns bytes. 52 # returns bytes.
54 getcwd = os.getcwdb 53 getcwd = os.getcwdb
167 stdout = sys.stdout 166 stdout = sys.stdout
168 stderr = sys.stderr 167 stderr = sys.stderr
169 sysargv = sys.argv 168 sysargv = sys.argv
170 sysplatform = sys.platform 169 sysplatform = sys.platform
171 getcwd = os.getcwd 170 getcwd = os.getcwd
172 osgetenv = os.getenv
173 sysexecutable = sys.executable 171 sysexecutable = sys.executable
174 shlexsplit = shlex.split 172 shlexsplit = shlex.split
175 173
176 stringio = io.StringIO 174 stringio = io.StringIO
177 empty = _queue.Empty 175 empty = _queue.Empty