From: Guido van Rossum Date: Wed, 25 Feb 1998 16:33:39 +0000 (+0000) Subject: Tweak the tb_lineno() function to be compatible with JPython, which X-Git-Tag: v1.5.1~575 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7266496b0043fa77375ebf31aceeff829aed8b80;p=python Tweak the tb_lineno() function to be compatible with JPython, which has no line number table etc. --- diff --git a/Lib/traceback.py b/Lib/traceback.py index d508e03dfe..d57963932a 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -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])