Re: [kvm-unit-tests PATCH] scripts/pretty_print_stacks.py: Silence warning from Python 3.12

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2023-12-19 at 14:23 +0100, Thomas Huth wrote:
> Python 3.12 complains:
> 
>  ./scripts/pretty_print_stacks.py:41: SyntaxWarning:
>   invalid escape sequence '\?'
>   m = re.match(b'(.*) at (.*):(([0-9]+)|\?)([^:]*)', line)
> 
> Switch to a raw string to silence the problem.
> 
> Signed-off-by: Thomas Huth <thuth@xxxxxxxxxx>
> ---
>  scripts/pretty_print_stacks.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/pretty_print_stacks.py b/scripts/pretty_print_stacks.py
> index d990d300..5bce84fc 100755
> --- a/scripts/pretty_print_stacks.py
> +++ b/scripts/pretty_print_stacks.py
> @@ -38,7 +38,7 @@ def pretty_print_stack(binary, line):
>          return
>  
>      for line in out.splitlines():
> -        m = re.match(b'(.*) at (.*):(([0-9]+)|\?)([^:]*)', line)
> +        m = re.match(r'(.*) at (.*):(([0-9]+)|\?)([^:]*)', line)

Did you test this? Should this not be rb'<regex>'?
I get
TypeError: cannot use a string pattern on a bytes-like object
When imitating this in a REPL.
We don't open the process in text mode, so its output should
be bytes and after splitting, "line" should be too.

>          if m is None:
>              puts('%s\n' % line)
>              return






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux