diff options
author | Michael W. Hudson <mwh@python.net> | 2002-08-15 14:59:02 (GMT) |
---|---|---|
committer | Michael W. Hudson <mwh@python.net> | 2002-08-15 14:59:02 (GMT) |
commit | dd32a91cc0c8ba178d7ee5e78c30b6920aff66f4 (patch) | |
tree | 1a2062b54d3445ca788fd63c2bc63984dd85f34a /Lib/inspect.py | |
parent | add88060c1d1a98c7970e35b326e6a65a17ddf04 (diff) | |
download | cpython-dd32a91cc0c8ba178d7ee5e78c30b6920aff66f4.zip cpython-dd32a91cc0c8ba178d7ee5e78c30b6920aff66f4.tar.gz cpython-dd32a91cc0c8ba178d7ee5e78c30b6920aff66f4.tar.bz2 |
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.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index be2da41..96677b7 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -711,7 +711,7 @@ def getframeinfo(frame, context=1): raise TypeError, 'arg is not a frame or traceback object' filename = getsourcefile(frame) or getfile(frame) - lineno = getlineno(frame) + lineno = frame.f_lineno if context > 0: start = lineno - 1 - context//2 try: @@ -730,18 +730,8 @@ def getframeinfo(frame, context=1): def getlineno(frame): """Get the line number from a frame object, allowing for optimization.""" - # Written by Marc-André Lemburg; revised by Jim Hugunin and Fredrik Lundh. - lineno = frame.f_lineno - code = frame.f_code - if hasattr(code, 'co_lnotab'): - table = code.co_lnotab - lineno = code.co_firstlineno - addr = 0 - for i in range(0, len(table), 2): - addr = addr + ord(table[i]) - if addr > frame.f_lasti: break - lineno = lineno + ord(table[i+1]) - return lineno + # FrameType.f_lineno is now a descriptor that grovels co_lnotab + return frame.f_lineno def getouterframes(frame, context=1): """Get a list of records for a frame and all higher (calling) frames. |