Skip to content

Commit 8a96b98

Browse files
committed
BUG: Clear the linecache before getting lines.
1 parent d0d0eb7 commit 8a96b98

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

line_profiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def show_func(filename, start_lineno, func_name, timings, unit, stream=None):
164164
nlines = max(linenos) - min(min(linenos), start_lineno) + 1
165165
sublines = [''] * nlines
166166
else:
167+
# Clear the cache to ensure that we get up-to-date results.
168+
linecache.clearcache()
167169
all_lines = linecache.getlines(filename)
168170
sublines = inspect.getblock(all_lines[start_lineno-1:])
169171
for lineno, nhits, time in timings:

0 commit comments

Comments
 (0)