mirror of
https://github.com/python/cpython.git
synced 2025-11-26 13:22:51 +00:00
[Bug #954364] inspect.getframeinfo() sometimes produces incorrect traceback line #s; fix is to look at tb.tb_lineno, not tb.frame.f_lineno. Patch from Robin Becker and me.
This commit is contained in:
parent
39aef79821
commit
ba8b6bc86f
2 changed files with 5 additions and 3 deletions
|
|
@ -740,12 +740,14 @@ def getframeinfo(frame, context=1):
|
|||
The optional second argument specifies the number of lines of context
|
||||
to return, which are centered around the current line."""
|
||||
if istraceback(frame):
|
||||
lineno = frame.tb_lineno
|
||||
frame = frame.tb_frame
|
||||
else:
|
||||
lineno = frame.f_lineno
|
||||
if not isframe(frame):
|
||||
raise TypeError('arg is not a frame or traceback object')
|
||||
|
||||
filename = getsourcefile(frame) or getfile(frame)
|
||||
lineno = frame.f_lineno
|
||||
if context > 0:
|
||||
start = lineno - 1 - context//2
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue