From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 10 Mar 2020 18:24:16 +0000 (-0700) Subject: tracemalloc: 'pretty top' example no longer changes the filename (GH-18903) X-Git-Tag: v3.7.8rc1~157 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f0fcf16902f440c2cddd6dec59aaf59a370d9dbf;p=thirdparty%2FPython%2Fcpython.git 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 d06eec218eac81225f9017951cddfc211fed9325) Co-authored-by: Adam Johnson --- diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst index 2d327c025409..000c0ee94059 100644 --- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -202,10 +202,8 @@ ignoring ```` and ```` files:: print("Top %s lines" % limit) for index, stat in enumerate(top_stats[:limit], 1): frame = stat.traceback[0] - # replace "/path/to/module/file.py" with "module/file.py" - filename = os.sep.join(frame.filename.split(os.sep)[-2:]) print("#%s: %s:%s: %.1f KiB" - % (index, filename, frame.lineno, stat.size / 1024)) + % (index, frame.filename, frame.lineno, stat.size / 1024)) line = linecache.getline(frame.filename, frame.lineno).strip() if line: print(' %s' % line)