changeset 39724:e1e10cbb5568

py3: make tests/svn-safe-append.py compatible with python 3 Differential Revision: https://phab.mercurial-scm.org/D4671
author Pulkit Goyal <pulkit@yandex-team.ru>
date Thu, 20 Sep 2018 17:17:02 +0300
parents 5495ceab5637
children be396c86f98e
files tests/svn-safe-append.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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