changeset 36677:6585ac350fd9

py3: make os.curdir a bytes
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Mar 2018 12:36:05 -0500
parents 052351e3e1cd
children d3b893ec5f08
files mercurial/hgweb/common.py mercurial/pycompat.py mercurial/templater.py
diffstat 3 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Sat Mar 03 12:34:35 2018 -0500
+++ b/mercurial/hgweb/common.py	Sat Mar 03 12:36:05 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, pycompat.ospardir) or
+        if (part in ('', pycompat.oscurdir, pycompat.ospardir) or
             pycompat.ossep in part or
             pycompat.osaltsep is not None and pycompat.osaltsep in part):
             return False
--- a/mercurial/pycompat.py	Sat Mar 03 12:34:35 2018 -0500
+++ b/mercurial/pycompat.py	Sat Mar 03 12:36:05 2018 -0500
@@ -48,6 +48,7 @@
 
     fsencode = os.fsencode
     fsdecode = os.fsdecode
+    oscurdir = os.curdir.encode('ascii')
     oslinesep = os.linesep.encode('ascii')
     osname = os.name.encode('ascii')
     ospathsep = os.pathsep.encode('ascii')
@@ -321,6 +322,7 @@
     strkwargs = identity
     byteskwargs = identity
 
+    oscurdir = os.curdir
     oslinesep = os.linesep
     osname = os.name
     ospathsep = os.pathsep
--- a/mercurial/templater.py	Sat Mar 03 12:34:35 2018 -0500
+++ b/mercurial/templater.py	Sat Mar 03 12:36:05 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, pycompat.ospardir)
+            or style in (pycompat.oscurdir, pycompat.ospardir)
             or pycompat.ossep in style
             or pycompat.osaltsep and pycompat.osaltsep in style):
             continue