8000 GH-96092: restore frame height of traceback.walk_stack to that of pyt… · python/cpython@2376fe7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2376fe7

Browse files
committed
GH-96092: restore frame height of traceback.walk_stack to that of python 3.10
1 parent 780757a commit 2376fe7

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Lib/test/test_traceback.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,6 +2243,7 @@ def deeper():
22432243
return list(traceback.walk_stack(None))
22442244
s1 = list(traceback.walk_stack(None))
22452245
s2 = deeper()
2246+
self.assertIs(s2[0][0].f_code, deeper.__code__)
22462247
self.assertEqual(len(s2) - len(s1), 1)
22472248
self.assertEqual(s2[1:], s1)
22482249

Lib/traceback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def walk_stack(f):
330330
current stack is used. Usually used with StackSummary.extract.
331331
"""
332332
if f is None:
333-
f = sys._getframe().f_back.f_back.f_back.f_back
333+
f = sys._getframe().f_back.f_back
334334
while f is not None:
335335
yield f, f.f_lineno
336336
f = f.f_back

0 commit comments

Comments
 (0)
0