Skip to content

Commit

Permalink
Convert bytes to string for re in get_tracepoints()
Browse files Browse the repository at this point in the history
When executing funccount with python3, the following error showed.

 # python3 funccount.py -D 't:block:*'
 Traceback (most recent call last):
   File "funccount.py", line 299, in <module>
     Tool().run()
   File "funccount.py", line 261, in run
     self.probe.load()
   File "funccount.py", line 191, in load
     bpf_text += self._generate_functions(trace_count_text)
   File "funccount.py", line 143, in _generate_functions
     tracepoints = BPF.get_tracepoints(self.pattern)
   File "/usr/lib/python3.7/site-packages/bcc/__init__.py", line 772, in get_tracepoints
     if re.match(tp_re, tp):
   File "/usr/lib64/python3.7/re.py", line 173, in match
     return _compile(pattern, flags).match(string)
 TypeError: cannot use a bytes pattern on a string-like object

This commit convert 'tp_re' from bytes to string to avoid the crash.

Signed-off-by: Gary Lin <[email protected]>
  • Loading branch information
lcp committed Apr 17, 2019
1 parent 9d035b8 commit d2a4626
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ def get_tracepoints(tp_re):
evt_dir = os.path.join(cat_dir, event)
if os.path.isdir(evt_dir):
tp = ("%s:%s" % (category, event))
if re.match(tp_re, tp):
if re.match(tp_re.decode(), tp):
results.append(tp)
return results

Expand Down

0 comments on commit d2a4626

Please sign in to comment.