scripts/pretty_print_stacks.py: Silence warning from Python 3.12
PATCH 1/1 scripts/pretty_print_stacks.py: Silence warning from Python 3.12
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.
--- scripts/pretty_print_stacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/pretty_print_stacks.py +1 -1
@@ -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
Signature · 1 line
2.43.0
Quoted 18 lines · Thomas Huth
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 <[email protected]>--- scripts/pretty_print_stacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/pretty_print_stacks.py +0
-0
scripts/pretty_print_stacks.py def pretty_print_stack(binary, line): · line 41
Quoted 5 lines
scripts/pretty_print_stacks.py +1
-1@@ -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.
Quoted 3 lines
scripts/pretty_print_stacks.py +0
-0if m is None: puts('%s\n' % line) return
Quoted 21 lines · Nina Schoetterl-Glausch
Quoted 20 lines · Thomas Huth
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 <[email protected]>--- scripts/pretty_print_stacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/pretty_print_stacks.py +0
-0@@ -38,7 +38,7 @@ def pretty_print_stack(binary, line): return
Quoted 7 lines
scripts/pretty_print_stacks.py def pretty_print_stack(binary, line): · line 41
Quoted 3 lines
scripts/pretty_print_stacks.py +1
-1for 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