Skip to content

Commit eb8ede2

Browse files
hhoffstaetteyonghong-song
authored andcommitted
*.py: fix "SyntaxWarning: invalid escape sequence" when using Python 3.12
Fixes: #4823 Signed-off-by: Holger Hoffstätte <[email protected]>
1 parent 4490b7e commit eb8ede2

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

examples/tracing/task_switch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from time import sleep
77

88
b = BPF(src_file="task_switch.c")
9-
b.attach_kprobe(event_re="^finish_task_switch$|^finish_task_switch\.isra\.\d$",
9+
b.attach_kprobe(event_re=r'^finish_task_switch$|^finish_task_switch.isra.d$',
1010
fn_name="count_sched")
1111

1212
# generate many schedule events

src/python/bcc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def get_kprobe_functions(event_re):
755755
elif fn.startswith(b'__SCT__'):
756756
continue
757757
# Exclude all gcc 8's extra .cold functions
758-
elif re.match(b'^.*\.cold(\.\d+)?$', fn):
758+
elif re.match(b'^.*.cold(.d+)?$', fn):
759759
continue
760760
if (t.lower() in [b't', b'w']) and re.fullmatch(event_re, fn) \
761761
and fn not in blacklist \

tests/python/test_tools_smoke.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def run_with_int(self, command, timeout=5, kill_timeout=5,
6464

6565
def kmod_loaded(self, mod):
6666
with open("/proc/modules", "r") as mods:
67-
reg = re.compile("^%s\s" % mod)
67+
reg = re.compile(r'^%s\s' % mod)
6868
for line in mods:
6969
if reg.match(line):
7070
return 1

tests/python/test_trace2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
class TestTracingEvent(TestCase):
3131
def setUp(self):
3232
b = BPF(text=text, debug=0)
33-
self.stats = b.get_table(b"stats")
34-
b.attach_kprobe(event_re=b"^finish_task_switch$|^finish_task_switch\.isra\.\d$",
35-
fn_name=b"count_sched")
33+
self.stats = b.get_table(b'stats')
34+
b.attach_kprobe(event_re=b'^finish_task_switch$|^finish_task_switch.isra.d$',
35+
fn_name=b'count_sched')
3636

3737
def test_sched1(self):
3838
for i in range(0, 100):

tools/exitsnoop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def initialize(arg_list = sys.argv[1:]):
204204
Global.args.timestamp = True
205205
if not Global.args.ebpf and os.geteuid() != 0:
206206
return (os.EX_NOPERM, "Need sudo (CAP_SYS_ADMIN) for BPF() system call")
207-
if re.match('^3\.10\..*el7.*$', platform.release()): # Centos/Red Hat
207+
if re.match(r'^3.10..*el7.*$', platform.release()): # Centos/Red Hat
208208
Global.args.timespec = True
209209
for _ in range(2):
210210
c = _embedded_c(Global.args)

0 commit comments

Comments
 (0)