Patchwork [2,of,6] py3: replace os.pathsep with pycompat.ospathsep

login
register
mail settings
Submitter Pulkit Goyal
Date Dec. 17, 2016, 3:41 p.m.
Message ID <32865b15b8417a3ad673.1481989301@pulkit-goyal>
Download mbox | patch
Permalink /patch/17944/
State Accepted
Headers show

Comments

Pulkit Goyal - Dec. 17, 2016, 3:41 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1481984237 -19800
#      Sat Dec 17 19:47:17 2016 +0530
# Node ID 32865b15b8417a3ad673b72ffc713dffdebcd04a
# Parent  ea408eb4d17eb54f68ffcbabb1c32cacfb64955d
py3: replace os.pathsep with pycompat.ospathsep

os.pathsep returns unicode on Python 3. We already have pycompat.ospathsep
which return bytes on Python 3. This patch replaces all the occurences of
os.pathsep in the codebase(excluding tests) to pycompat.ospathsep.

Patch

diff -r ea408eb4d17e -r 32865b15b841 mercurial/posix.py
--- a/mercurial/posix.py	Sat Dec 17 19:36:40 2016 +0530
+++ b/mercurial/posix.py	Sat Dec 17 19:47:17 2016 +0530
@@ -23,6 +23,7 @@ 
 from .i18n import _
 from . import (
     encoding,
+    pycompat,
 )
 
 posixfile = open
@@ -461,7 +462,7 @@ 
     if sys.platform == 'plan9':
         return findexisting(os.path.join('/bin', command))
 
-    for path in os.environ.get('PATH', '').split(os.pathsep):
+    for path in os.environ.get('PATH', '').split(pycompat.ospathsep):
         executable = findexisting(os.path.join(path, command))
         if executable is not None:
             return executable
diff -r ea408eb4d17e -r 32865b15b841 mercurial/scmwindows.py
--- a/mercurial/scmwindows.py	Sat Dec 17 19:36:40 2016 +0530
+++ b/mercurial/scmwindows.py	Sat Dec 17 19:47:17 2016 +0530
@@ -4,6 +4,7 @@ 
 
 from . import (
     osutil,
+    pycompat,
     util,
     win32,
 )
@@ -33,7 +34,7 @@ 
     if not isinstance(value, str) or not value:
         return rcpath
     value = util.localpath(value)
-    for p in value.split(os.pathsep):
+    for p in value.split(pycompat.ospathsep):
         if p.lower().endswith('mercurial.ini'):
             rcpath.append(p)
         elif os.path.isdir(p):
diff -r ea408eb4d17e -r 32865b15b841 mercurial/windows.py
--- a/mercurial/windows.py	Sat Dec 17 19:36:40 2016 +0530
+++ b/mercurial/windows.py	Sat Dec 17 19:47:17 2016 +0530
@@ -18,6 +18,7 @@ 
 from . import (
     encoding,
     osutil,
+    pycompat,
     win32,
 )
 
@@ -303,7 +304,7 @@ 
     An extension from PATHEXT is found and added if not present.
     If command isn't found None is returned.'''
     pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD')
-    pathexts = [ext for ext in pathext.lower().split(os.pathsep)]
+    pathexts = [ext for ext in pathext.lower().split(pycompat.ospathsep)]
     if os.path.splitext(command)[1].lower() in pathexts:
         pathexts = ['']
 
@@ -318,7 +319,7 @@ 
     if os.sep in command:
         return findexisting(command)
 
-    for path in os.environ.get('PATH', '').split(os.pathsep):
+    for path in os.environ.get('PATH', '').split(pycompat.ospathsep):
         executable = findexisting(os.path.join(path, command))
         if executable is not None:
             return executable