[ python-Bugs-973092 ] inspect.getframeinfo bug if 'context' is to
big
SourceForge.net
noreply at sourceforge.net
Tue Jun 15 05:09:52 EDT 2004
Bugs item #973092, was opened at 2004-06-15 11:09
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=973092&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Hans Georg Krauthaeuser (krauthae)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect.getframeinfo bug if 'context' is to big
Initial Comment:
In inspect.getframeinfo index gets wrong if context is
larger than len(lines).
the lines are:
...
if context > 0:
start = lineno - 1 - context//2
try:
lines, lnum = findsource(frame)
except IOError:
lines = index = None
else:
start = max(start, 1)
start = min(start, len(lines) - context)
^^^^^^^^^^^^^^^^^^^^^^^^
lines = lines[start:start+context]
index = lineno - 1 - start
else:
lines = index = None
...
The 'min' statement gives a negative start if context
is to large. As a result index gets to large.
The solution is just to put
context = min(context,len(lines))
after the first 'else:'
Regards
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=973092&group_id=5470
More information about the Python-bugs-list
mailing list