Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f170d7f

Browse files
committed
Don't have trace() skip the top frame; return them all.
1 parent 6526bf8 commit f170d7f

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

Lib/inspect.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,6 @@ def getinnerframes(tb, context=1):
620620
621621
Each record contains a frame object, filename, line number, function
622622
name, a list of lines of context, and index within the context."""
623-
tb = tb.tb_next
624623
framelist = []
625624
while tb:
626625
framelist.append((tb.tb_frame,) + getframeinfo(tb, context))

Lib/test/test_inspect.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,14 @@ def sourcerange(top, bottom):
169169
istest(inspect.istraceback, 'git.ex[2]')
170170
istest(inspect.isframe, 'mod.fr')
171171

172-
test(len(git.tr) == 2, 'trace() length')
173-
test(git.tr[0][1:] == (TESTFN, 9, 'spam', [' eggs(b + d, c + f)\n'], 0),
174-
'trace() row 1')
175-
test(git.tr[1][1:] == (TESTFN, 18, 'eggs', [' q = y / 0\n'], 0),
172+
test(len(git.tr) == 3, 'trace() length')
173+
test(git.tr[0][1:] == (TESTFN, 46, 'argue',
174+
[' self.tr = inspect.trace()\n'], 0),
176175
'trace() row 2')
176+
test(git.tr[1][1:] == (TESTFN, 9, 'spam', [' eggs(b + d, c + f)\n'], 0),
177+
'trace() row 2')
178+
test(git.tr[2][1:] == (TESTFN, 18, 'eggs', [' q = y / 0\n'], 0),
179+
'trace() row 3')
177180

178181
test(len(mod.st) >= 5, 'stack() length')
179182
test(mod.st[0][1:] ==
@@ -188,7 +191,6 @@ def sourcerange(top, bottom):
188191
test(mod.st[3][1:] ==
189192
(TESTFN, 39, 'abuse', [' self.argue(a, b, c)\n'], 0),
190193
'stack() row 4')
191-
# row 4 is in test_inspect.py
192194

193195
args, varargs, varkw, locals = inspect.getargvalues(mod.fr)
194196
test(args == ['x', 'y'], 'mod.fr args')

0 commit comments

Comments
 (0)