From patchwork Sun Aug 25 16:21:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 34262 Received: (qmail 14153 invoked by alias); 25 Aug 2019 16:21:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14140 invoked by uid 89); 25 Aug 2019 16:21:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Greylist:Sun, eventually, HTo:U*gdb-patches, HX-Languages-Length:2842 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 Aug 2019 16:21:41 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4C98308AA11 for ; Sun, 25 Aug 2019 16:21:40 +0000 (UTC) Received: from psique.yyz.redhat.com (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA79760F82; Sun, 25 Aug 2019 16:21:37 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Sergio Durigan Junior Subject: [PATCH] Use raw strings on gdb.python/py-xmethods.exp (and fix Python 3.8's "SyntaxWarning: invalid escape sequence") Date: Sun, 25 Aug 2019 12:21:36 -0400 Message-Id: <20190825162136.22727-1-sergiodj@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes The way unrecognized escape sequences are handled has changed in Python 3.8: users now see a SyntaxWarning message, which will eventually become a SyntaxError in future versions of Python: (gdb) source /blabla/gdb.python/py-xmethods/py-xmethods.py /blabla/gdb.python/py-xmethods/py-xmethods.py:204: SyntaxWarning: invalid escape seque nce \+ 'operator\+', /blabla/gdb.python/py-xmethods/py-xmethods.py:211: SyntaxWarning: invalid escape seque nce \+ 'operator\+\+', One of our testcases, gdb.python/py-xmethods.exp, contains strings in the form of "operator\+". This is not recognized by Python, but is still needed by the testsuite to work properly. The solution is simple: we just have to make sure these strings are marked as raw (i.e, r""). This is what this patch does. I took the opportunity to also convert other strings to raw, which, in two cases, allowed the removal of an extra backslash. I tested this using Python 3.7 and Python 3.8, and everything works fine. I think I could push this as obvious, but decided to send it to gdb-patches just in case. gdb/testsuite/ChangeLog: 2019-08-25 Sergio Durigan Junior * gdb.python/py-xmethods.exp: Use raw strings when passing arguments to SimpleXMethodMatcher. --- gdb/testsuite/gdb.python/py-xmethods.py | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-xmethods.py b/gdb/testsuite/gdb.python/py-xmethods.py index 587842d736..cea48b80d8 100644 --- a/gdb/testsuite/gdb.python/py-xmethods.py +++ b/gdb/testsuite/gdb.python/py-xmethods.py @@ -199,34 +199,34 @@ class G_methods_matcher(XMethodMatcher): global_dm_list = [ - SimpleXMethodMatcher('A_plus_A', - '^dop::A$', - 'operator\+', + SimpleXMethodMatcher(r'A_plus_A', + r'^dop::A$', + r'operator\+', A_plus_A, # This is a replacement, hence match the arg type # exactly! type_A.const().reference()), - SimpleXMethodMatcher('plus_plus_A', - '^dop::A$', - 'operator\+\+', + SimpleXMethodMatcher(r'plus_plus_A', + r'^dop::A$', + r'operator\+\+', plus_plus_A), - SimpleXMethodMatcher('A_geta', - '^dop::A$', - '^geta$', + SimpleXMethodMatcher(r'A_geta', + r'^dop::A$', + r'^geta$', A_geta), - SimpleXMethodMatcher('A_getarrayind', - '^dop::A$', - '^getarrayind$', + SimpleXMethodMatcher(r'A_getarrayind', + r'^dop::A$', + r'^getarrayind$', A_getarrayind, type_int), - SimpleXMethodMatcher('A_indexoper', - '^dop::A$', - 'operator\\[\\]', + SimpleXMethodMatcher(r'A_indexoper', + r'^dop::A$', + r'operator\[\]', A_indexoper, type_int), - SimpleXMethodMatcher('B_indexoper', - '^dop::B$', - 'operator\\[\\]', + SimpleXMethodMatcher(r'B_indexoper', + r'^dop::B$', + r'operator\[\]', B_indexoper, type_int) ]