[v2] test_printers_common.py: Remove invalid escape sequence

Message ID 20240212140650.908586-1-hjl.tools@gmail.com
State Committed
Commit c676808a34e27fc3f7b1115c5257b382c6f00cb4
Headers
Series [v2] test_printers_common.py: Remove invalid escape sequence |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 warning Patch is already merged
redhat-pt-bot/TryBot-32bit fail Patch series failed to apply
linaro-tcwg-bot/tcwg_glibc_build--master-arm warning Patch is already merged

Commit Message

H.J. Lu Feb. 12, 2024, 2:06 p.m. UTC
  Change "\(" and "\)" to "\\(" and "\\)" in test_printers_common.py.  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

Florian Weimer Feb. 12, 2024, 2:14 p.m. UTC | #1
* H. J. Lu:

> Change "\(" and "\)" to "\\(" and "\\)" in test_printers_common.py.  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..5c0d936fed 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 version looks okay to me.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian
  
Joseph Myers Feb. 12, 2024, 5:55 p.m. UTC | #2
On Mon, 12 Feb 2024, H.J. Lu wrote:

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

It's generally better to use r'' strings to avoid needing to double 
backslashes.  And u'' is obsolete in Python 3 (and our scripts don't 
support Python 2 any more) so should not be used.
  

Patch

diff --git a/scripts/test_printers_common.py b/scripts/test_printers_common.py
index bf700966ac..5c0d936fed 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: