mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
add88060c1
commit
dd32a91cc0
19 changed files with 341 additions and 187 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue