Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uobjnew and ustat on python3 #959

Merged
merged 3 commits into from
Feb 10, 2017
Merged

Conversation

r4f4
Copy link
Contributor

@r4f4 r4f4 commented Feb 10, 2017

No description provided.

This fixes a TypeError in python 3, e.g, when executing uobjnew

Traceback (most recent call last):
  File "./uobjnew", line 134, in <module>
    bpf = BPF(text=program, usdt_contexts=[usdt])
  File "/usr/lib/python3.5/site-packages/bcc/__init__.py", line 224, in __init__
    text = usdt_text + text
TypeError: can't concat bytes to str
$ ./uobjnew
  File "./uobjnew", line 150
    data = sorted(data.items(), key=lambda (k, v): v.num_allocs)
                                           ^
SyntaxError: invalid syntax
$ ./ustat
  File "./ustat", line 242
    counts = sorted(counts.items(), key=lambda (_, v):
                                               ^
SyntaxError: invalid syntax
@drzaeus77 drzaeus77 merged commit 5467ccf into iovisor:master Feb 10, 2017
@r4f4 r4f4 deleted the fix-uobjnew branch February 10, 2017 18:27
@@ -239,10 +239,10 @@ def _loop_iter(self):
counts.update(probe.get_counts(self.bpf))
targets.update(probe.targets)
if self.args.sort:
counts = sorted(counts.items(), key=lambda (_, v):
counts = sorted(counts.items(), key=lambda _, v:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now broken on Python 2.x

data = data[-args.top_size:]
else:
data = sorted(data.items(), key=lambda (k, v): v.total_size)
data = sorted(data.items(), key=lambda k, v: v.total_size)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now broken on Python 2.x

@r4f4 r4f4 restored the fix-uobjnew branch February 13, 2017 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants