Skip to content

Commit

Permalink
Fixup tplist and argdist for python3 compat
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Brenden Blanco committed May 5, 2016
1 parent 977091e commit bc94d4c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def _check_path_symbol(cls, module, symname, addr):

@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):
Expand Down
4 changes: 2 additions & 2 deletions tools/argdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ def run(self):
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__":
Expand Down
4 changes: 2 additions & 2 deletions tools/tplist.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ def print_usdt(pid, lib):
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])

0 comments on commit bc94d4c

Please sign in to comment.