Skip to content

Commit

Permalink
Fix BPF(src_file="foo")
Browse files Browse the repository at this point in the history
Since commit 75f20a1 ("Use string type for comparison to PATH
elements"), src_file isn't working anymore. Somehow, two wrongs
(ArgString __str__() returning a bytes object and joining a bytes and
what was supposed to be a string) did make a right.

It fixes the following error in netqtop and deadlock:
Traceback (most recent call last):
  File "/usr/share/bcc/tools/netqtop", line 207, in <module>
    b = BPF(src_file = EBPF_FILE)
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 335, in __init__
    src_file = BPF._find_file(src_file)
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 255, in _find_file
    t = b"/".join([os.path.abspath(os.path.dirname(argv0.__str__())), filename])
TypeError: sequence item 0: expected a bytes-like object, str found
  • Loading branch information
jeromemarchand authored and yonghong-song committed Apr 29, 2021
1 parent e0c8c10 commit 09dc278
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 @@ -252,7 +252,7 @@ def _find_file(filename):
if filename:
if not os.path.isfile(filename):
argv0 = ArgString(sys.argv[0])
t = b"/".join([os.path.abspath(os.path.dirname(argv0.__str__())), filename])
t = b"/".join([os.path.abspath(os.path.dirname(argv0.__bytes__())), filename])
if os.path.isfile(t):
filename = t
else:
Expand Down

0 comments on commit 09dc278

Please sign in to comment.