changeset 39904:5fe0b880200e

py3: convert os.readlink() path to native strings on Windows Windows insisted that it needs to be str. I skipped the stuff in the posix module, and left `tests/f` and `run-tests.py` alone for now.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 25 Sep 2018 21:16:12 -0400
parents 803b7569c9ea
children 4017968f0a1d
files hgext/convert/gnuarch.py mercurial/posix.py mercurial/util.py mercurial/vfs.py mercurial/windows.py
diffstat 5 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/gnuarch.py	Sat Sep 29 02:02:35 2018 -0400
+++ b/hgext/convert/gnuarch.py	Tue Sep 25 21:16:12 2018 -0400
@@ -223,7 +223,7 @@
     def _getfile(self, name, rev):
         mode = os.lstat(os.path.join(self.tmppath, name)).st_mode
         if stat.S_ISLNK(mode):
-            data = os.readlink(os.path.join(self.tmppath, name))
+            data = util.readlink(os.path.join(self.tmppath, name))
             if mode:
                 mode = 'l'
             else:
--- a/mercurial/posix.py	Sat Sep 29 02:02:35 2018 -0400
+++ b/mercurial/posix.py	Tue Sep 25 21:16:12 2018 -0400
@@ -43,6 +43,7 @@
     def oslink(src, dst):
         raise OSError(errno.EINVAL,
                       'hardlinks not supported: %s to %s' % (src, dst))
+readlink = os.readlink
 unlink = os.unlink
 rename = os.rename
 removedirs = os.removedirs
--- a/mercurial/util.py	Sat Sep 29 02:02:35 2018 -0400
+++ b/mercurial/util.py	Tue Sep 25 21:16:12 2018 -0400
@@ -112,6 +112,7 @@
 pconvert = platform.pconvert
 poll = platform.poll
 posixfile = platform.posixfile
+readlink = platform.readlink
 rename = platform.rename
 removedirs = platform.removedirs
 samedevice = platform.samedevice
@@ -1841,7 +1842,7 @@
 
 def readlock(pathname):
     try:
-        return os.readlink(pathname)
+        return readlink(pathname)
     except OSError as why:
         if why.errno not in (errno.EINVAL, errno.ENOSYS):
             raise
--- a/mercurial/vfs.py	Sat Sep 29 02:02:35 2018 -0400
+++ b/mercurial/vfs.py	Tue Sep 25 21:16:12 2018 -0400
@@ -206,7 +206,7 @@
         return util.rename(srcpath, dstpath)
 
     def readlink(self, path):
-        return os.readlink(self.join(path))
+        return util.readlink(self.join(path))
 
     def removedirs(self, path=None):
         """Remove a leaf directory and all empty intermediate ones
--- a/mercurial/windows.py	Sat Sep 29 02:02:35 2018 -0400
+++ b/mercurial/windows.py	Tue Sep 25 21:16:12 2018 -0400
@@ -519,6 +519,9 @@
     If gid is None, return the name of the current group."""
     return None
 
+def readlink(pathname):
+    return pycompat.fsencode(os.readlink(pycompat.fsdecode(pathname)))
+
 def removedirs(name):
     """special version of os.removedirs that does not remove symlinked
     directories or junction points if they actually contain files"""