Patchwork [1,of,2] py3: do I/O in bytes in test-help.t

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 13, 2018, 12:28 p.m.
Message ID <b8a16cf84c34d254df7f.1539433706@mimosa>
Download mbox | patch
Permalink /patch/35893/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 13, 2018, 12:28 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1539432672 -7200
#      Sat Oct 13 14:11:12 2018 +0200
# Node ID b8a16cf84c34d254df7ff276e49e6d5fd327eb8b
# Parent  8603435ad64c35c4472726350e391076ad25c3aa
py3: do I/O in bytes in test-help.t
Pulkit Goyal - Oct. 13, 2018, 1:10 p.m.
On Sat, Oct 13, 2018 at 3:32 PM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1539432672 -7200
> #      Sat Oct 13 14:11:12 2018 +0200
> # Node ID b8a16cf84c34d254df7ff276e49e6d5fd327eb8b
> # Parent  8603435ad64c35c4472726350e391076ad25c3aa
> py3: do I/O in bytes in test-help.t
>

Queued this series, many thanks!

Patch

diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1799,13 +1799,13 @@  such str.lower().
 
   $ "$PYTHON" <<EOF
   > def escape(s):
-  >     return ''.join('\u%x' % ord(uc) for uc in s.decode('cp932'))
+  >     return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
   > # translation of "record" in ja_JP.cp932
-  > upper = "\x8bL\x98^"
+  > upper = b"\x8bL\x98^"
   > # str.lower()-ed section name should be treated as different one
-  > lower = "\x8bl\x98^"
-  > with open('ambiguous.py', 'w') as fp:
-  >     fp.write("""# ambiguous section names in ja_JP.cp932
+  > lower = b"\x8bl\x98^"
+  > with open('ambiguous.py', 'wb') as fp:
+  >     fp.write(b"""# ambiguous section names in ja_JP.cp932
   > u'''summary of extension
   > 
   > %s
@@ -1832,8 +1832,9 @@  such str.lower().
   > EOF
 
   $ "$PYTHON" <<EOF | sh
-  > upper = "\x8bL\x98^"
-  > print("hg --encoding cp932 help -e ambiguous.%s" % upper)
+  > from mercurial import pycompat
+  > upper = b"\x8bL\x98^"
+  > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
   > EOF
   \x8bL\x98^ (esc)
   ----
@@ -1842,8 +1843,9 @@  such str.lower().
   
 
   $ "$PYTHON" <<EOF | sh
-  > lower = "\x8bl\x98^"
-  > print("hg --encoding cp932 help -e ambiguous.%s" % lower)
+  > from mercurial import pycompat
+  > lower = b"\x8bl\x98^"
+  > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
   > EOF
   \x8bl\x98^ (esc)
   ----