py3: have bytes version of os.getenv
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 19 Dec 2016 02:35:38 +0530
changeset 30666 bb0d5aad761a
parent 30665 69459fdf3b1b
child 30667 69acfd2ca11e
py3: have bytes version of os.getenv os.getenv() on python 3 deals with unicodes. If we want to pass bytes. we have os.getenvb() which deals with bytes. This patch adds up a pycompat.osgetenv which deals with bytes on both python 2 and 3.
mercurial/pycompat.py
--- a/mercurial/pycompat.py	Sat Dec 24 01:16:14 2016 +0530
+++ b/mercurial/pycompat.py	Mon Dec 19 02:35:38 2016 +0530
@@ -45,6 +45,7 @@
     ospathsep = os.pathsep.encode('ascii')
     ossep = os.sep.encode('ascii')
     osaltsep = os.altsep
+    osgetenv = os.getenvb
     if osaltsep:
         osaltsep = osaltsep.encode('ascii')
     # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
@@ -156,6 +157,7 @@
     sysargv = sys.argv
     sysplatform = sys.platform
     getcwd = os.getcwd
+    osgetenv = os.getenv
 
 stringio = io.StringIO
 empty = _queue.Empty