py3: make tests/svn-safe-append.py compatible with python 3
authorPulkit Goyal <pulkit@yandex-team.ru>
Thu, 20 Sep 2018 17:17:02 +0300
changeset 39724 e1e10cbb5568
parent 39723 5495ceab5637
child 39725 be396c86f98e
py3: make tests/svn-safe-append.py compatible with python 3 Differential Revision: https://phab.mercurial-scm.org/D4671
tests/svn-safe-append.py
--- a/tests/svn-safe-append.py	Thu Sep 20 17:16:16 2018 +0300
+++ b/tests/svn-safe-append.py	Thu Sep 20 17:17:02 2018 +0300
@@ -9,14 +9,18 @@
 import stat
 import sys
 
-text = sys.argv[1]
-fname = sys.argv[2]
+if sys.version_info[0] >= 3:
+    text = os.fsencode(sys.argv[1])
+    fname = os.fsencode(sys.argv[2])
+else:
+    text = sys.argv[1]
+    fname = sys.argv[2]
 
 f = open(fname, "ab")
 try:
     before = os.fstat(f.fileno())[stat.ST_MTIME]
     f.write(text)
-    f.write("\n")
+    f.write(b"\n")
 finally:
     f.close()
 inc = 1