Skip to content

Commit

Permalink
*.py: fix "SyntaxWarning: invalid escape sequence" when using Python …
Browse files Browse the repository at this point in the history
…3.12

Fixes: #4823

Signed-off-by: Holger Hoffstätte <[email protected]>
  • Loading branch information
hhoffstaette authored and yonghong-song committed Dec 8, 2023
1 parent 4490b7e commit eb8ede2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/tracing/task_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from time import sleep

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

# generate many schedule events
Expand Down
2 changes: 1 addition & 1 deletion src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ def get_kprobe_functions(event_re):
elif fn.startswith(b'__SCT__'):
continue
# Exclude all gcc 8's extra .cold functions
elif re.match(b'^.*\.cold(\.\d+)?$', fn):
elif re.match(b'^.*.cold(.d+)?$', fn):
continue
if (t.lower() in [b't', b'w']) and re.fullmatch(event_re, fn) \
and fn not in blacklist \
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_tools_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run_with_int(self, command, timeout=5, kill_timeout=5,

def kmod_loaded(self, mod):
with open("/proc/modules", "r") as mods:
reg = re.compile("^%s\s" % mod)
reg = re.compile(r'^%s\s' % mod)
for line in mods:
if reg.match(line):
return 1
Expand Down
6 changes: 3 additions & 3 deletions tests/python/test_trace2.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
class TestTracingEvent(TestCase):
def setUp(self):
b = BPF(text=text, debug=0)
self.stats = b.get_table(b"stats")
b.attach_kprobe(event_re=b"^finish_task_switch$|^finish_task_switch\.isra\.\d$",
fn_name=b"count_sched")
self.stats = b.get_table(b'stats')
b.attach_kprobe(event_re=b'^finish_task_switch$|^finish_task_switch.isra.d$',
fn_name=b'count_sched')

def test_sched1(self):
for i in range(0, 100):
Expand Down
2 changes: 1 addition & 1 deletion tools/exitsnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def initialize(arg_list = sys.argv[1:]):
Global.args.timestamp = True
if not Global.args.ebpf and os.geteuid() != 0:
return (os.EX_NOPERM, "Need sudo (CAP_SYS_ADMIN) for BPF() system call")
if re.match('^3\.10\..*el7.*$', platform.release()): # Centos/Red Hat
if re.match(r'^3.10..*el7.*$', platform.release()): # Centos/Red Hat
Global.args.timespec = True
for _ in range(2):
c = _embedded_c(Global.args)
Expand Down

0 comments on commit eb8ede2

Please sign in to comment.