From dd32a91cc0c8ba178d7ee5e78c30b6920aff66f4 Mon Sep 17 00:00:00 2001 From: "Michael W. Hudson" Date: Thu, 15 Aug 2002 14:59:02 +0000 Subject: This is my patch [ 587993 ] SET_LINENO killer Remove SET_LINENO. Tracing is now supported by inspecting co_lnotab. Many sundry changes to document and adapt to this change. --- Lib/traceback.py | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'Lib/traceback.py') diff --git a/Lib/traceback.py b/Lib/traceback.py index c22f576798..4910a37cb0 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -59,7 +59,7 @@ def print_tb(tb, limit=None, file=None): n = 0 while tb is not None and (limit is None or n < limit): f = tb.tb_frame - lineno = tb_lineno(tb) + lineno = tb.tb_lineno co = f.f_code filename = co.co_filename name = co.co_name @@ -92,7 +92,7 @@ def extract_tb(tb, limit = None): n = 0 while tb is not None and (limit is None or n < limit): f = tb.tb_frame - lineno = tb_lineno(tb) + lineno = tb.tb_lineno co = f.f_code filename = co.co_filename name = co.co_name @@ -263,7 +263,7 @@ def extract_stack(f=None, limit = None): list = [] n = 0 while f is not None and (limit is None or n < limit): - lineno = f.f_lineno # XXX Too bad if -O is used + lineno = f.f_lineno co = f.f_code filename = co.co_filename name = co.co_name @@ -279,23 +279,6 @@ def extract_stack(f=None, limit = None): def tb_lineno(tb): """Calculate correct line number of traceback given in tb. - Even works with -O on. + Obsolete in 2.3. """ - # Coded by Marc-Andre Lemburg from the example of PyCode_Addr2Line() - # in compile.c. - # Revised version by Jim Hugunin to work with JPython too. - - c = tb.tb_frame.f_code - if not hasattr(c, 'co_lnotab'): - return tb.tb_lineno - - tab = c.co_lnotab - line = c.co_firstlineno - stopat = tb.tb_lasti - addr = 0 - for i in range(0, len(tab), 2): - addr = addr + ord(tab[i]) - if addr > stopat: - break - line = line + ord(tab[i+1]) - return line + return tb.tb_lineno -- cgit v1.2.1