summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/inspect.py4
-rw-r--r--Lib/test/test_inspect.py4
2 files changed, 5 insertions, 3 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:
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 3ff08b7..bdbec41 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -158,8 +158,8 @@ istest(inspect.istraceback, 'git.ex[2]')
istest(inspect.isframe, 'mod.fr')
test(len(git.tr) == 3, 'trace() length')
-test(git.tr[0][1:] == (TESTFN, 46, 'argue',
- [' self.tr = inspect.trace()\n'], 0),
+test(git.tr[0][1:] == (TESTFN, 43, 'argue',
+ [' spam(a, b, c)\n'], 0),
'trace() row 2')
test(git.tr[1][1:] == (TESTFN, 9, 'spam', [' eggs(b + d, c + f)\n'], 0),
'trace() row 2')