Issue #15812: inspect.getframeinfo() now correctly shows the first li… · python/cpython@ff0e3b7 · GitHub
Skip to content

Commit ff0e3b7

Browse files
committed
Issue #15812: inspect.getframeinfo() now correctly shows the first line of a context
Patch by Sam Breese.
1 parent 4950ae1 commit ff0e3b7

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lib/inspect.py

Lines changed: 1 addition & 1 deletion

Lib/test/test_inspect.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ def test_getmodule(self):
391391
# Check filename override
392392
self.assertEqual(inspect.getmodule(None, modfile), mod)
393393

394+
def test_getframeinfo_get_first_line(self):
395+
frame_info = inspect.getframeinfo(self.fodderModule.fr, 50)
396+
self.assertEqual(frame_info.code_context[0], "# line 1\n")
397+
self.assertEqual(frame_info.code_context[1], "'A module docstring.'\n")
398+
394399
def test_getsource(self):
395400
self.assertSourceEqual(git.abuse, 29, 39)
396401
self.assertSourceEqual(mod.StupidGit, 21, 51)

Misc/NEWS

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)