This repository was archived by the owner on Feb 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed
Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1416,7 +1416,7 @@ def getframeinfo(frame, context=1):
14161416 except OSError :
14171417 lines = index = None
14181418 else :
1419- start = max (start , 1 )
1419+ start = max (start , 0 )
14201420 start = max (0 , min (start , len (lines ) - context ))
14211421 lines = lines [start :start + context ]
14221422 index = lineno - 1 - start
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change @@ -140,6 +140,9 @@ Core and Builtins
140140Library
141141-------
142142
143+ - Issue #15812: inspect.getframeinfo() now correctly shows the first line of
144+ a context. Patch by Sam Breese.
145+
143146- Issue #29094: Offsets in a ZIP file created with extern file object and modes
144147 "w" and "x" now are relative to the start of the file.
145148
You can’t perform that action at this time.
0 commit comments