diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2004-06-05 14:11:59 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2004-06-05 14:11:59 (GMT) |
commit | ba8b6bc86fcb00b37a53f8edd8f38c4b0e77f3a5 (patch) | |
tree | 7e86e9f0ed052b5173e1c8d1e204fb4da599683d /Lib/inspect.py | |
parent | 39aef79821d9ad8d428b14b59190bd0ca0c550d9 (diff) | |
download | cpython-ba8b6bc86fcb00b37a53f8edd8f38c4b0e77f3a5.zip cpython-ba8b6bc86fcb00b37a53f8edd8f38c4b0e77f3a5.tar.gz cpython-ba8b6bc86fcb00b37a53f8edd8f38c4b0e77f3a5.tar.bz2 |
[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.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 0e0e9e5..8a58ce9 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -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: |