Patchwork [2,of,4] py3: have a bytes version of os.altsep

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

Comments

Pulkit Goyal - Dec. 18, 2016, 12:01 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1482002061 -19800
#      Sun Dec 18 00:44:21 2016 +0530
# Node ID ffdca92474e806c84d0e3383768b3011202d650e
# Parent  af87471131e2fecc9e6edeb2a5c2e155953da4bb
py3: have a bytes version of os.altsep

os.altsep returns unicodes on Python 3. We need a bytes version hence added
pycompat.altsep.

Patch

diff -r af87471131e2 -r ffdca92474e8 mercurial/pycompat.py
--- a/mercurial/pycompat.py	Sat Dec 17 23:55:25 2016 +0530
+++ b/mercurial/pycompat.py	Sun Dec 18 00:44:21 2016 +0530
@@ -44,6 +44,9 @@ 
     osname = os.name.encode('ascii')
     ospathsep = os.pathsep.encode('ascii')
     ossep = os.sep.encode('ascii')
+    osaltsep = os.altsep
+    if osaltsep:
+        osaltsep = osaltsep.encode('ascii')
     # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
     # returns bytes.
     getcwd = os.getcwdb
@@ -145,6 +148,7 @@ 
     osname = os.name
     ospathsep = os.pathsep
     ossep = os.sep
+    osaltsep = os.altsep
     stdin = sys.stdin
     stdout = sys.stdout
     stderr = sys.stderr