]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Bug #954364] inspect.getframeinfo() sometimes produces incorrect traceback line...
authorAndrew M. Kuchling <amk@amk.ca>
Sat, 5 Jun 2004 14:14:49 +0000 (14:14 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sat, 5 Jun 2004 14:14:49 +0000 (14:14 +0000)
Lib/inspect.py
Lib/test/test_inspect.py
Misc/NEWS

index 1f49bcb3a19792fb983e25292b44b2cdeca45a45..bc6033328f4a86321117bfdb0a66924b2fc34291 100644 (file)
@@ -739,12 +739,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:
index 3ff08b7d8a8cae66ed632adc103427db7391b049..bdbec41ff458cf82730e9860d05d099c7cb20986 100644 (file)
@@ -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')
index 4a91a6645a75a38198be28513d3671959916ad24..52da68f261e9d9d77533a4d1ae3c2ee0657bdb92 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,8 @@ Extension modules
 
 - Bug #841757: xmlrpclib failed on structs with Unicode keys.
 
+- Bug #954364: inspect.getframeinfo() sometimes produces incorrect traceback 
+  line numbers
 
 What's New in Python 2.3.4 (final)?
 ===================================