[PATCH V2] py3: convert os.readlink() path to native strings

Matt Harbison mharbison72 at gmail.com
Fri Sep 28 02:51:27 UTC 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1537924572 14400
#      Tue Sep 25 21:16:12 2018 -0400
# Node ID 216114ff8d2bc57d9aa8913cf75f14267a8332f6
# Parent  df02cb5b9b3496aa95cbe754a92d714f4c68262b
py3: convert os.readlink() path to native strings

Windows insisted that it needs to be str.  I skipped the stuff that's obviously
posix only, and left `tests/f` and `run-tests.py` alone for now.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1841,7 +1841,7 @@ def makelock(info, pathname):
 
 def readlock(pathname):
     try:
-        return os.readlink(pathname)
+        return pycompat.fsencode(os.readlink(pycompat.fsdecode(pathname)))
     except OSError as why:
         if why.errno not in (errno.EINVAL, errno.ENOSYS):
             raise
diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -206,7 +206,8 @@ class abstractvfs(object):
         return util.rename(srcpath, dstpath)
 
     def readlink(self, path):
-        return os.readlink(self.join(path))
+        abspath = self.join(path)
+        return pycompat.fsencode(os.readlink(pycompat.fsdecode(abspath)))
 
     def removedirs(self, path=None):
         """Remove a leaf directory and all empty intermediate ones


More information about the Mercurial-devel mailing list