Mercurial > public > mercurial-scm > hg-stable
diff mercurial/util.py @ 30618:1112ff99d965
py3: replace os.sep with pycompat.ossep (part 1 of 4)
os.sep returns unicodes on Python 3. We have pycompat.ossep which returns
bytes. This patch is a part of 4 patch series which will replace all the
occurrences of os.sep to pycompat.ossep
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 17 Dec 2016 19:56:30 +0530 |
parents | 98d7636c4729 |
children | bcf4a975f93d |
line wrap: on
line diff
--- a/mercurial/util.py Sat Dec 17 19:47:17 2016 +0530 +++ b/mercurial/util.py Sat Dec 17 19:56:30 2016 +0530 @@ -916,7 +916,7 @@ a.pop() b.pop() b.reverse() - return os.sep.join((['..'] * len(a)) + b) or '.' + return pycompat.ossep.join((['..'] * len(a)) + b) or '.' def mainfrozen(): """return True if we are a frozen executable. @@ -1303,7 +1303,7 @@ def _makefspathcacheentry(dir): return dict((normcase(n), n) for n in os.listdir(dir)) - seps = os.sep + seps = pycompat.ossep if os.altsep: seps = seps + os.altsep # Protect backslashes. This gets silly very quickly. @@ -1370,7 +1370,8 @@ def endswithsep(path): '''Check path ends with os.sep or os.altsep.''' - return path.endswith(os.sep) or os.altsep and path.endswith(os.altsep) + return (path.endswith(pycompat.ossep) + or os.altsep and path.endswith(os.altsep)) def splitpath(path): '''Split path by os.sep. @@ -1378,7 +1379,7 @@ an alternative of simple "xxx.split(os.sep)". It is recommended to use os.path.normpath() before using this function if need.''' - return path.split(os.sep) + return path.split(pycompat.ossep) def gui(): '''Are we running in a GUI?'''