Fix issue #1744. (#1746)
- Fix a crash in the python binding when trying to open a perf buffer
in python < 3.6
- See https://github.com/iovisor/bcc/issues/1744
diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py
index 4cb4cf6..faea319 100644
--- a/src/python/bcc/__init__.py
+++ b/src/python/bcc/__init__.py
@@ -445,12 +445,12 @@
if map_fd < 0:
raise KeyError
if not keytype:
- key_desc = lib.bpf_table_key_desc(self.module, name)
+ key_desc = lib.bpf_table_key_desc(self.module, name).decode("utf-8")
if not key_desc:
raise Exception("Failed to load BPF Table %s key desc" % name)
keytype = BPF._decode_table_type(json.loads(key_desc))
if not leaftype:
- leaf_desc = lib.bpf_table_leaf_desc(self.module, name)
+ leaf_desc = lib.bpf_table_leaf_desc(self.module, name).decode("utf-8")
if not leaf_desc:
raise Exception("Failed to load BPF Table %s leaf desc" % name)
leaftype = BPF._decode_table_type(json.loads(leaf_desc))