Patchwork py3: fix bad escapes of sub() replacement pattern in test-template-basic.t

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 14, 2018, 12:47 p.m.
Message ID <55d0252b56e9af55bc4c.1544791660@mimosa>
Download mbox | patch
Permalink /patch/37137/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 14, 2018, 12:47 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1544789959 -32400
#      Fri Dec 14 21:19:19 2018 +0900
# Node ID 55d0252b56e9af55bc4ccbda921fdd01f0c2ff54
# Parent  eed9a62e1f1098f641aacd3de6e0d84d53a1cdd6
py3: fix bad escapes of sub() replacement pattern in test-template-basic.t

Python 3.7 starts complaining about it. We have to double the backslash or
'\x5c' to get around.
Pulkit Goyal - Dec. 14, 2018, 3:41 p.m.
On Fri, Dec 14, 2018 at 3:49 PM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1544789959 -32400
> #      Fri Dec 14 21:19:19 2018 +0900
> # Node ID 55d0252b56e9af55bc4ccbda921fdd01f0c2ff54
> # Parent  eed9a62e1f1098f641aacd3de6e0d84d53a1cdd6
> py3: fix bad escapes of sub() replacement pattern in test-template-basic.t
>
> Python 3.7 starts complaining about it. We have to double the backslash or
> '\x5c' to get around.
>

Ah, not sure I should look at Python 3.7 with anger or at Python 2.7.
Anyway queued this, many thanks.

Patch

diff --git a/tests/test-template-basic.t b/tests/test-template-basic.t
--- a/tests/test-template-basic.t
+++ b/tests/test-template-basic.t
@@ -860,7 +860,7 @@  Test string escaping in nested expressio
   $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n'
   fourth\x5c\x786esecond\x5c\x786ethird
 
-  $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n'
+  $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\\x5c\\x786e", "\x5c\x5c\x786e"), desc)}\n'
   3:\x6eo user, \x6eo domai\x6e
   4:\x5c\x786eew bra\x5c\x786ech