changeset 36053:3c9f2d4dbb39

py3: replace file() with open() in test-convert-hg-source.t file() is not present in Python 3. It also makes sure we read and write in bytes mode on Python 3. Differential Revision: https://phab.mercurial-scm.org/D2132
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 11 Feb 2018 17:17:05 +0530
parents af9cb761b5f3
children fe5c4b795999
files tests/test-convert-hg-source.t
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-convert-hg-source.t	Sun Feb 11 17:15:45 2018 +0530
+++ b/tests/test-convert-hg-source.t	Sun Feb 11 17:17:05 2018 +0530
@@ -126,9 +126,9 @@
   $ cat > rewrite.py <<EOF
   > import sys
   > # Interlace LF and CRLF
-  > lines = [(l.rstrip() + ((i % 2) and '\n' or '\r\n'))
-  >          for i, l in enumerate(file(sys.argv[1]))]
-  > file(sys.argv[1], 'wb').write(''.join(lines))
+  > lines = [(l.rstrip() + ((i % 2) and b'\n' or b'\r\n'))
+  >          for i, l in enumerate(open(sys.argv[1], 'rb'))]
+  > open(sys.argv[1], 'wb').write(b''.join(lines))
   > EOF
   $ $PYTHON rewrite.py new/.hg/shamap
   $ cd orig