Patchwork [3,of,4] py3: make os.curdir a bytes

login
register
mail settings
Submitter Yuya Nishihara
Date March 3, 2018, 7:38 p.m.
Message ID <2222c0fd1e4f0e387a84.1520105894@mimosa>
Download mbox | patch
Permalink /patch/28812/
State Accepted
Headers show

Comments

Yuya Nishihara - March 3, 2018, 7:38 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1520098565 18000
#      Sat Mar 03 12:36:05 2018 -0500
# Node ID 2222c0fd1e4f0e387a841794b7542c12d15f40c1
# Parent  e6c7422051775cd8c5e50f77b2bdd5a399cb9342
py3: make os.curdir a bytes

Patch

diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -138,7 +138,7 @@  def ispathsafe(path):
     """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
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -48,6 +48,7 @@  if ispy3:
 
     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 @@  else:
     strkwargs = identity
     byteskwargs = identity
 
+    oscurdir = os.curdir
     oslinesep = os.linesep
     osname = os.name
     ospathsep = os.pathsep
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1600,7 +1600,7 @@  def stylemap(styles, paths=None):
     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