Patchwork [3,of,4] py3: have a bytes version of sys.platform

login
register
mail settings
Submitter Pulkit Goyal
Date Dec. 18, 2016, 12:01 p.m.
Message ID <e737d795d5813e66ce7a.1482062493@pulkit-goyal>
Download mbox | patch
Permalink /patch/17953/
State Accepted
Headers show

Comments

Pulkit Goyal - Dec. 18, 2016, 12:01 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1482002525 -19800
#      Sun Dec 18 00:52:05 2016 +0530
# Node ID e737d795d5813e66ce7a57a74fa30f52f6eb4ec4
# Parent  ffdca92474e806c84d0e3383768b3011202d650e
py3: have a bytes version of sys.platform

sys.platform returns unicodes on Python 3. This patch adds up
pycompat.sysplatform which returns bytes.

Patch

diff -r ffdca92474e8 -r e737d795d581 mercurial/pycompat.py
--- a/mercurial/pycompat.py	Sun Dec 18 00:44:21 2016 +0530
+++ b/mercurial/pycompat.py	Sun Dec 18 00:52:05 2016 +0530
@@ -50,6 +50,7 @@ 
     # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
     # returns bytes.
     getcwd = os.getcwdb
+    sysplatform = sys.platform.encode('ascii')
 
     # TODO: .buffer might not exist if std streams were replaced; we'll need
     # a silly wrapper to make a bytes stream backed by a unicode one.
@@ -153,6 +154,7 @@ 
     stdout = sys.stdout
     stderr = sys.stderr
     sysargv = sys.argv
+    sysplatform = sys.platform
     getcwd = os.getcwd
 
 stringio = io.StringIO