changeset 39759:aeb2812f304d

py3: fix a type error in hghave.has_hardlink test-hghave.t was failing with: feature hardlink failed: argument 1: <class 'TypeError'>: wrong type
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 21 Sep 2018 00:37:03 -0400
parents 543f26ece6cf
children 7e99b02768ef
files tests/hghave.py
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tests/hghave.py	Fri Sep 21 09:34:41 2018 -0700
+++ b/tests/hghave.py	Fri Sep 21 00:37:03 2018 -0400
@@ -16,6 +16,22 @@
     "false": (lambda: False, "nail clipper"),
 }
 
+if sys.version_info[0] >= 3:
+    def _bytespath(p):
+        if p is None:
+            return p
+        return p.encode('utf-8')
+
+    def _strpath(p):
+        if p is None:
+            return p
+        return p.decode('utf-8')
+else:
+    def _bytespath(p):
+        return p
+
+    _strpath = _bytespath
+
 def check(name, desc):
     """Registers a check function for a feature."""
     def decorator(func):
@@ -360,7 +376,7 @@
     os.close(fh)
     name = tempfile.mktemp(dir='.', prefix=tempprefix)
     try:
-        util.oslink(fn, name)
+        util.oslink(_bytespath(fn), _bytespath(name))
         os.unlink(name)
         return True
     except OSError: