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

Unicode decode error #24

Closed
vmig opened this issue Aug 15, 2018 · 4 comments
Closed

Unicode decode error #24

vmig opened this issue Aug 15, 2018 · 4 comments

Comments

@vmig
Copy link

vmig commented Aug 15, 2018

tuna cannot parse a cProfile dump file. This is a stack trace:

$ tuna cprofile.dat
Traceback (most recent call last):
  File "~/.virtualenvs/profiling/bin/tuna", line 11, in <module>
    sys.exit(main())
  File "~/.virtualenvs/profiling/lib/python3.6/site-packages/tuna/cli.py", line 13, in main
    start_server(args.infile, args.browser)
  File "~/.virtualenvs/profiling/lib/python3.6/site-packages/tuna/main.py", line 134, in start_server
    data = read(prof_filename)
  File "~/.virtualenvs/profiling/lib/python3.6/site-packages/tuna/main.py", line 21, in read
    return read_import_profile(filename)
  File "~/.virtualenvs/profiling/lib/python3.6/site-packages/tuna/main.py", line 93, in read_import_profile
    assert next(import_lines) == "self [us] | cumulative | imported package"
  File "~/.virtualenvs/profiling/lib/python3.6/site-packages/tuna/main.py", line 89, in <genexpr>
    line[len("import time: ") :].rstrip()
  File "~/.virtualenvs/profiling/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfb in position 0: invalid start byte
@nschloe
Copy link
Owner

nschloe commented Aug 15, 2018

I cannot reproduce this without the profile.

@vmig
Copy link
Author

vmig commented Aug 15, 2018

This is an example of a cProfile dump.
cprofile.log

@nschloe
Copy link
Owner

nschloe commented Aug 15, 2018

Alright, I fixed a bug that prevented your file from being read. Another error though pertains:

AssertionError: The default root node `<built-in method builtins.exec>` was not found in the profile. 

Not sure why this node isn't present in your profile.

@vmig
Copy link
Author

vmig commented Aug 15, 2018

I generated the profile file inside a code. This is an example:

profile = cProfile.Profile()
profile.enable()
result = expensive_function()
profile.disable()
profile.dump_stats("cprofile.log")

In this case the <built-in method builtins.exec> is absent.

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

No branches or pull requests

2 participants