From 3aebfadda6777c90e797bba749665ff108f521d2 Mon Sep 17 00:00:00 2001 From: Nageswara R Sastry Date: Fri, 11 Jan 2019 22:27:23 +0530 Subject: [PATCH] syscall.py: Fixes python3 related error With out the patch: Traceback (most recent call last):$ File "/root/bcc/src/python/bcc/syscall.py", line 381, in $ out = out.split('\n',1)[1]$ TypeError: a bytes-like object is required, not 'str'$ $ During handling of the above exception, another exception occurred:$ $ Traceback (most recent call last):$ File "/root/bcc/tests/python/test_stat1.py", line 10, in $ from bcc import BPF$ File "/root/bcc/src/python/bcc/__init__.py", line 30, in $ from .syscall import syscall_name$ File "/root/bcc/src/python/bcc/syscall.py", line 387, in $ raise Exception("ausyscall: command not found")$ Exception: ausyscall: command not found$ This is because variable 'out' is a byte object type and while split, code is passing 'str' type. Tested this on python3 and python2 Signed-off-by: Nageswara R Sastry --- src/python/bcc/syscall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/bcc/syscall.py b/src/python/bcc/syscall.py index 65ccc92d0773..752b64ed8f17 100644 --- a/src/python/bcc/syscall.py +++ b/src/python/bcc/syscall.py @@ -378,7 +378,7 @@ def _parse_syscall(line): # SYSCALL_NUM\tSYSCALL_NAME pairs. out = subprocess.check_output(['ausyscall', '--dump'], stderr=subprocess.STDOUT) # remove the first line of expected output - out = out.split('\n',1)[1] + out = out.split(b'\n',1)[1] syscalls = dict(map(_parse_syscall, out.strip().split(b'\n'))) except Exception as e: if platform.machine() == "x86_64":