]> granicus.if.org Git - python/commitdiff
Tweak the tb_lineno() function to be compatible with JPython, which
authorGuido van Rossum <guido@python.org>
Wed, 25 Feb 1998 16:33:39 +0000 (16:33 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 25 Feb 1998 16:33:39 +0000 (16:33 +0000)
has no line number table etc.

Lib/traceback.py

index d508e03dfe9ab6f9724ba90fc40c143e5dfcb879..d57963932afb9edcde8550fa2a136f3b80b3db21 100644 (file)
@@ -188,10 +188,14 @@ def extract_stack(f=None, limit = None):
 # in compile.c.
 
 def tb_lineno(tb):
-       c = tb.tb_frame.f_code
-       tab = c.co_lnotab
-       line = c.co_firstlineno
-       stopat = tb.tb_lasti
+       f = tb.tb_frame
+       try:
+               c = f.f_code
+               tab = c.co_lnotab
+               line = c.co_firstlineno
+               stopat = tb.tb_lasti
+       except AttributeError:
+               return f.f_lineno
        addr = 0
        for i in range(0, len(tab), 2):
                addr = addr + ord(tab[i])