changeset 36647:052351e3e1cd

py3: make os.pardir a bytes
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Mar 2018 12:34:35 -0500
parents 463df2986814
children 6585ac350fd9
files mercurial/hgweb/common.py mercurial/pathutil.py mercurial/pycompat.py mercurial/templater.py
diffstat 4 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Sat Mar 03 14:21:47 2018 -0500
+++ b/mercurial/hgweb/common.py	Sat Mar 03 12:34:35 2018 -0500
@@ -138,7 +138,7 @@
     """Determine if a path is safe to use for filesystem access."""
     parts = path.split('/')
     for part in parts:
-        if (part in ('', os.curdir, os.pardir) or
+        if (part in ('', os.curdir, pycompat.ospardir) or
             pycompat.ossep in part or
             pycompat.osaltsep is not None and pycompat.osaltsep in part):
             return False
--- a/mercurial/pathutil.py	Sat Mar 03 14:21:47 2018 -0500
+++ b/mercurial/pathutil.py	Sat Mar 03 12:34:35 2018 -0500
@@ -65,7 +65,7 @@
         parts = util.splitpath(path)
         if (os.path.splitdrive(path)[0]
             or _lowerclean(parts[0]) in ('.hg', '.hg.', '')
-            or os.pardir in parts):
+            or pycompat.ospardir in parts):
             raise error.Abort(_("path contains illegal component: %s") % path)
         # Windows shortname aliases
         for p in parts:
--- a/mercurial/pycompat.py	Sat Mar 03 14:21:47 2018 -0500
+++ b/mercurial/pycompat.py	Sat Mar 03 12:34:35 2018 -0500
@@ -51,6 +51,7 @@
     oslinesep = os.linesep.encode('ascii')
     osname = os.name.encode('ascii')
     ospathsep = os.pathsep.encode('ascii')
+    ospardir = os.pardir.encode('ascii')
     ossep = os.sep.encode('ascii')
     osaltsep = os.altsep
     if osaltsep:
@@ -323,6 +324,7 @@
     oslinesep = os.linesep
     osname = os.name
     ospathsep = os.pathsep
+    ospardir = os.pardir
     ossep = os.sep
     osaltsep = os.altsep
     stdin = sys.stdin
--- a/mercurial/templater.py	Sat Mar 03 14:21:47 2018 -0500
+++ b/mercurial/templater.py	Sat Mar 03 12:34:35 2018 -0500
@@ -1600,7 +1600,7 @@
     for style in styles:
         # only plain name is allowed to honor template paths
         if (not style
-            or style in (os.curdir, os.pardir)
+            or style in (os.curdir, pycompat.ospardir)
             or pycompat.ossep in style
             or pycompat.osaltsep and pycompat.osaltsep in style):
             continue