8000 tracemalloc: 'pretty top' example no longer changes the filename (GH-… · python/cpython@f0fcf16 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0fcf16

Browse files
tracemalloc: 'pretty top' example no longer changes the filename (GH-18903)
I've used this recipe a couple times and the filename editing has always been less than useful and something I've removed. This is because many modules end up losing which package they are located in, e.g. `util/date.py`. (cherry picked from commit d06eec2) Co-authored-by: Adam Johnson <me@adamj.eu>
1 parent 5b29a82 commit f0fcf16

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Doc/library/tracemalloc.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,8 @@ ignoring ``<frozen importlib._bootstrap>`` and ``<unknown>`` files::
202202
print("Top %s lines" % limit)
203203
for index, stat in enumerate(top_stats[:limit], 1):
204204
frame = stat.traceback[0]
205-
# replace "/path/to/module/file.py" with "module/file.py"
206-
filename = os.sep.join(frame.filename.split(os.sep)[-2:])
207205
print("#%s: %s:%s: %.1f KiB"
208-
% (index, filename, frame.lineno, stat.size / 1024))
206+
% (index, frame.filename, frame.lineno, stat.size / 1024))
209207
line = linecache.getline(frame.filename, frame.lineno).strip()
210208
if line:
211209
print(' %s' % line)

0 commit comments

Comments
 (0)
0