From bc94d4c12eb0b35e63db9be0ba8cbcbac05be44d Mon Sep 17 00:00:00 2001 From: Brenden Blanco Date: Thu, 5 May 2016 12:05:07 -0700 Subject: [PATCH] Fixup tplist and argdist for python3 compat sys.exc_value and sys.exc_type should come from sys.exc_info() Convert (decode) char* return values from C functions to a native python str. Signed-off-by: Brenden Blanco --- src/python/bcc/__init__.py | 2 +- tools/argdist.py | 4 ++-- tools/tplist.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py index b425813..3a7755a 100644 --- a/src/python/bcc/__init__.py +++ b/src/python/bcc/__init__.py @@ -446,7 +446,7 @@ class BPF(object): @staticmethod def find_library(libname): - return lib.bcc_procutils_which_so(libname) + return lib.bcc_procutils_which_so(libname.encode("ascii")).decode() def attach_uprobe(self, name="", sym="", addr=None, fn_name="", pid=-1, cpu=0, group_fd=-1): diff --git a/tools/argdist.py b/tools/argdist.py index 89f57c3..9d71442 100755 --- a/tools/argdist.py +++ b/tools/argdist.py @@ -673,8 +673,8 @@ struct __string_t { char s[%d]; }; except: if self.args.verbose: traceback.print_exc() - elif sys.exc_type is not SystemExit: - print(sys.exc_value) + elif sys.exc_info()[0] is not SystemExit: + print(sys.exc_info()[1]) self._close_probes() if __name__ == "__main__": diff --git a/tools/tplist.py b/tools/tplist.py index abb011d..ff00744 100755 --- a/tools/tplist.py +++ b/tools/tplist.py @@ -86,6 +86,6 @@ if __name__ == "__main__": else: print_tracepoints() except: - if sys.exc_type is not SystemExit: - print(sys.exc_value) + if sys.exc_info()[0] is not SystemExit: + print(sys.exc_info()[1]) -- 2.7.4