diff mbox series

test_printers_common.py: Remove invalid escape sequence

Message ID 20240212133532.159366-1-hjl.tools@gmail.com
State New
Headers show
Series test_printers_common.py: Remove invalid escape sequence | expand

Commit Message

H.J. Lu Feb. 12, 2024, 1:35 p.m. UTC
Remove '\(' and '\)' from test_printers_common.py which aren't valid
Python escape sequences.  This fixes the test warning:

.../scripts/test_printers_common.py:101: SyntaxWarning: invalid escape sequence '\('
---
 scripts/test_printers_common.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Schwab Feb. 12, 2024, 1:44 p.m. UTC | #1
On Feb 12 2024, H.J. Lu wrote:

> diff --git a/scripts/test_printers_common.py b/scripts/test_printers_common.py
> index bf700966ac..7085a2fbc2 100644
> --- a/scripts/test_printers_common.py
> +++ b/scripts/test_printers_common.py
> @@ -98,7 +98,7 @@ try:
>      # If everything's ok, spawn the gdb process we'll use for testing.
>      gdb = pexpect.spawn(gdb_invocation, echo=False, timeout=timeout,
>                          encoding=encoding)
> -    gdb_prompt = u'\(gdb\)'
> +    gdb_prompt = u'(gdb)'

When that's a regexp it needs to be '\\(gdb\\)'.
Florian Weimer Feb. 12, 2024, 1:47 p.m. UTC | #2
* H. J. Lu:

> Remove '\(' and '\)' from test_printers_common.py which aren't valid
> Python escape sequences.  This fixes the test warning:
>
> .../scripts/test_printers_common.py:101: SyntaxWarning: invalid escape sequence '\('
> ---
>  scripts/test_printers_common.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/test_printers_common.py b/scripts/test_printers_common.py
> index bf700966ac..7085a2fbc2 100644
> --- a/scripts/test_printers_common.py
> +++ b/scripts/test_printers_common.py
> @@ -98,7 +98,7 @@ try:
>      # If everything's ok, spawn the gdb process we'll use for testing.
>      gdb = pexpect.spawn(gdb_invocation, echo=False, timeout=timeout,
>                          encoding=encoding)
> -    gdb_prompt = u'\(gdb\)'
> +    gdb_prompt = u'(gdb)'
>      gdb.expect(gdb_prompt)
>  
>  except pexpect.ExceptionPexpect as exception:

This changes the string, you should use:

+    gdb_prompt = u'\\(gdb\\)'

Thanks,
Florian
H.J. Lu Feb. 12, 2024, 1:55 p.m. UTC | #3
On Mon, Feb 12, 2024 at 5:47 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > Remove '\(' and '\)' from test_printers_common.py which aren't valid
> > Python escape sequences.  This fixes the test warning:
> >
> > .../scripts/test_printers_common.py:101: SyntaxWarning: invalid escape sequence '\('
> > ---
> >  scripts/test_printers_common.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/scripts/test_printers_common.py b/scripts/test_printers_common.py
> > index bf700966ac..7085a2fbc2 100644
> > --- a/scripts/test_printers_common.py
> > +++ b/scripts/test_printers_common.py
> > @@ -98,7 +98,7 @@ try:
> >      # If everything's ok, spawn the gdb process we'll use for testing.
> >      gdb = pexpect.spawn(gdb_invocation, echo=False, timeout=timeout,
> >                          encoding=encoding)
> > -    gdb_prompt = u'\(gdb\)'
> > +    gdb_prompt = u'(gdb)'
> >      gdb.expect(gdb_prompt)
> >
> >  except pexpect.ExceptionPexpect as exception:
>
> This changes the string, you should use:
>
> +    gdb_prompt = u'\\(gdb\\)'
>

This change, \\( and \\), causes:

FAIL: nptl/test-cond-printers
FAIL: nptl/test-condattr-printers
FAIL: nptl/test-mutex-printers
FAIL: nptl/test-mutexattr-printers
FAIL: nptl/test-rwlock-printers
FAIL: nptl/test-rwlockattr-printers

My change doesn't have any regression.
Florian Weimer Feb. 12, 2024, 2:03 p.m. UTC | #4
* H. J. Lu:

> On Mon, Feb 12, 2024 at 5:47 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu:
>>
>> > Remove '\(' and '\)' from test_printers_common.py which aren't valid
>> > Python escape sequences.  This fixes the test warning:
>> >
>> > .../scripts/test_printers_common.py:101: SyntaxWarning: invalid escape sequence '\('
>> > ---
>> >  scripts/test_printers_common.py | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/scripts/test_printers_common.py b/scripts/test_printers_common.py
>> > index bf700966ac..7085a2fbc2 100644
>> > --- a/scripts/test_printers_common.py
>> > +++ b/scripts/test_printers_common.py
>> > @@ -98,7 +98,7 @@ try:
>> >      # If everything's ok, spawn the gdb process we'll use for testing.
>> >      gdb = pexpect.spawn(gdb_invocation, echo=False, timeout=timeout,
>> >                          encoding=encoding)
>> > -    gdb_prompt = u'\(gdb\)'
>> > +    gdb_prompt = u'(gdb)'
>> >      gdb.expect(gdb_prompt)
>> >
>> >  except pexpect.ExceptionPexpect as exception:
>>
>> This changes the string, you should use:
>>
>> +    gdb_prompt = u'\\(gdb\\)'
>>
>
> This change, \\( and \\), causes:
>
> FAIL: nptl/test-cond-printers
> FAIL: nptl/test-condattr-printers
> FAIL: nptl/test-mutex-printers
> FAIL: nptl/test-mutexattr-printers
> FAIL: nptl/test-rwlock-printers
> FAIL: nptl/test-rwlockattr-printers
>
> My change doesn't have any regression.

I don't understand that.  Python 2.7.5 and 3.11.7 treat u'\(gdb\)' as
u'\\(gdb\\)'.

Thanks,
Florian
H.J. Lu Feb. 12, 2024, 2:07 p.m. UTC | #5
On Mon, Feb 12, 2024 at 6:03 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Mon, Feb 12, 2024 at 5:47 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu:
> >>
> >> > Remove '\(' and '\)' from test_printers_common.py which aren't valid
> >> > Python escape sequences.  This fixes the test warning:
> >> >
> >> > .../scripts/test_printers_common.py:101: SyntaxWarning: invalid escape sequence '\('
> >> > ---
> >> >  scripts/test_printers_common.py | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/scripts/test_printers_common.py b/scripts/test_printers_common.py
> >> > index bf700966ac..7085a2fbc2 100644
> >> > --- a/scripts/test_printers_common.py
> >> > +++ b/scripts/test_printers_common.py
> >> > @@ -98,7 +98,7 @@ try:
> >> >      # If everything's ok, spawn the gdb process we'll use for testing.
> >> >      gdb = pexpect.spawn(gdb_invocation, echo=False, timeout=timeout,
> >> >                          encoding=encoding)
> >> > -    gdb_prompt = u'\(gdb\)'
> >> > +    gdb_prompt = u'(gdb)'
> >> >      gdb.expect(gdb_prompt)
> >> >
> >> >  except pexpect.ExceptionPexpect as exception:
> >>
> >> This changes the string, you should use:
> >>
> >> +    gdb_prompt = u'\\(gdb\\)'
> >>
> >
> > This change, \\( and \\), causes:
> >
> > FAIL: nptl/test-cond-printers
> > FAIL: nptl/test-condattr-printers
> > FAIL: nptl/test-mutex-printers
> > FAIL: nptl/test-mutexattr-printers
> > FAIL: nptl/test-rwlock-printers
> > FAIL: nptl/test-rwlockattr-printers
> >
> > My change doesn't have any regression.
>
> I don't understand that.  Python 2.7.5 and 3.11.7 treat u'\(gdb\)' as
> u'\\(gdb\\)'.
>
> Thanks,
> Florian
>

Pilot error.  Sent v2.
diff mbox series

Patch

diff --git a/scripts/test_printers_common.py b/scripts/test_printers_common.py
index bf700966ac..7085a2fbc2 100644
--- a/scripts/test_printers_common.py
+++ b/scripts/test_printers_common.py
@@ -98,7 +98,7 @@  try:
     # If everything's ok, spawn the gdb process we'll use for testing.
     gdb = pexpect.spawn(gdb_invocation, echo=False, timeout=timeout,
                         encoding=encoding)
-    gdb_prompt = u'\(gdb\)'
+    gdb_prompt = u'(gdb)'
     gdb.expect(gdb_prompt)
 
 except pexpect.ExceptionPexpect as exception: