Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] scripts/pretty_print_stacks.py: Silence warning from Python 3.12
@ 2023-12-19 13:23 Thomas Huth
  2023-12-19 14:52 ` Nina Schoetterl-Glausch
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Huth @ 2023-12-19 13:23 UTC (permalink / raw)
  To: kvm; +Cc: Nina Schoetterl-Glausch, Andrew Jones, Paolo Bonzini

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@redhat.com>
---
 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)
         if m is None:
             puts('%s\n' % line)
             return
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH] scripts/pretty_print_stacks.py: Silence warning from Python 3.12
  2023-12-19 13:23 [kvm-unit-tests PATCH] scripts/pretty_print_stacks.py: Silence warning from Python 3.12 Thomas Huth
@ 2023-12-19 14:52 ` Nina Schoetterl-Glausch
  2023-12-19 15:29   ` Thomas Huth
  0 siblings, 1 reply; 3+ messages in thread
From: Nina Schoetterl-Glausch @ 2023-12-19 14:52 UTC (permalink / raw)
  To: Thomas Huth, kvm; +Cc: Andrew Jones, Paolo Bonzini

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@redhat.com>
> ---
>  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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH] scripts/pretty_print_stacks.py: Silence warning from Python 3.12
  2023-12-19 14:52 ` Nina Schoetterl-Glausch
@ 2023-12-19 15:29   ` Thomas Huth
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2023-12-19 15:29 UTC (permalink / raw)
  To: Nina Schoetterl-Glausch, kvm; +Cc: Andrew Jones, Paolo Bonzini

On 19/12/2023 15.52, Nina Schoetterl-Glausch wrote:
> 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@redhat.com>
>> ---
>>   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

Drat, of course I only tested it in the sense that I made sure that the 
python warning goes away when running the run_test.sh script, but I did not 
trigger a backtrace ...

You're right of course, it has to be rb'...' here instead. I'll send a v2.

  Thomas


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-19 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 13:23 [kvm-unit-tests PATCH] scripts/pretty_print_stacks.py: Silence warning from Python 3.12 Thomas Huth
2023-12-19 14:52 ` Nina Schoetterl-Glausch
2023-12-19 15:29   ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox