This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Use raw strings on gdb.python/py-xmethods.exp (and fix Python 3.8's "SyntaxWarning: invalid escape sequence")
- From: Simon Marchi <simark at simark dot ca>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>, GDB Patches <gdb-patches at sourceware dot org>
- Date: Sun, 25 Aug 2019 18:44:37 -0400
- Subject: Re: [PATCH] Use raw strings on gdb.python/py-xmethods.exp (and fix Python 3.8's "SyntaxWarning: invalid escape sequence")
- References: <20190825162136.22727-1-sergiodj@redhat.com>
On 2019-08-25 12:21 p.m., Sergio Durigan Junior wrote:
> 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.
Just to understand correctly, could you have also changed
'operator\+'
to
'operator\\+'
?
In any case, I think using raw strings is a good solution, it requires less escaping, so your patch LGTM.
Simon