changeset 36030:b85b0bbed6de

py3: replace file() with open() in test-eol.t file() is not present in Python 3. This patch also adds a b'' prefix to make sure we write bytes in Python 3. Differential Revision: https://phab.mercurial-scm.org/D2129
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 11 Feb 2018 17:14:00 +0530
parents d83fc41dabf3
children acda1977210c
files tests/test-eol.t
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-eol.t	Sun Feb 11 17:13:11 2018 +0530
+++ b/tests/test-eol.t	Sun Feb 11 17:14:00 2018 +0530
@@ -17,12 +17,12 @@
   >     msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
   > except ImportError:
   >     pass
-  > (old, new) = sys.argv[1] == 'LF' and ('\n', '\r\n') or ('\r\n', '\n')
+  > (old, new) = sys.argv[1] == 'LF' and (b'\n', b'\r\n') or (b'\r\n', b'\n')
   > print("%% switching encoding from %r to %r" % (old, new))
   > for path in sys.argv[2:]:
-  >     data = file(path, 'rb').read()
+  >     data = open(path, 'rb').read()
   >     data = data.replace(old, new)
-  >     file(path, 'wb').write(data)
+  >     open(path, 'wb').write(data)
   > EOF
 
   $ seteol () {