[PATCH 1 of 7] py3: have bytes version of os.getenv

Pulkit Goyal 7895pulkit at gmail.com
Wed Dec 21 17:03:46 EST 2016


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1482095138 -19800
#      Mon Dec 19 02:35:38 2016 +0530
# Node ID eee84d7c0647a50d4e9828b324e1e37214abd169
# Parent  e995f00a9e9afda3734e7880df0fc90fd2197a88
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.

diff -r e995f00a9e9a -r eee84d7c0647 mercurial/pycompat.py
--- a/mercurial/pycompat.py	Mon Dec 19 02:26:41 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


More information about the Mercurial-devel mailing list