Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Python 3 attempting to view lprof file. #170

Open
bobhancock opened this issue Nov 11, 2019 · 1 comment
Open

Python 3 attempting to view lprof file. #170

bobhancock opened this issue Nov 11, 2019 · 1 comment

Comments

@bobhancock
Copy link

Cmd Line: kernprof -v ./simply.py.lprof

Some of the report is displayed and then this staacktrace below. I inserted a pdb.set_trace() in kernprof.py and the filename is correct and the file handle also.

Traceback (most recent call last):
File "/usr/bin/kernprof", line 11, in
load_entry_point('line-profiler==2.1.1', 'console_scripts', 'kernprof')()
File "/usr/local/google/home/rwh/.local/lib/python3.7/site-packages/kernprof.py", line 226, in main
prof.runctx('execfile_(%r, globals())' % (script_file,), ns, ns)
File "/usr/local/google/home/rwh/python/src/pyenv/versions/3.7.0/lib/python3.7/cProfile.py", line 100, in runctx
exec(cmd, globals, locals)
File "", line 1, in
File "/usr/local/google/home/rwh/.local/lib/python3.7/site-packages/kernprof.py", line 36, in execfile
with open(filename, 'rb') as f:
ValueError: source code string cannot contain null bytes

try:
execfile
except NameError:
# Python 3.x doesn't have 'execfile' builtin
import builtins
exec_ = getattr(builtins, "exec")

def execfile(filename, globals=None, locals=None):
   pdb.set_trace()
    with open(filename, 'rb') as f:
        exec_(compile(f.read(), filename, 'exec'), globals, locals)
@tharwan
Copy link

tharwan commented Feb 5, 2020

same here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants