Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert bytes to string for re in get_tracepoints() #2318

Merged
merged 1 commit into from
Apr 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Convert bytes to string for re in get_tracepoints()
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
commit d2a4626dacc33d3dca9a7e6ea2ef4bdaa6ef3c74
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