]> granicus.if.org Git - python/commitdiff
SF bug #973092: inspect.getframeinfo bug if 'context' is to big
authorRaymond Hettinger <python@rcn.com>
Tue, 15 Jun 2004 11:22:53 +0000 (11:22 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 15 Jun 2004 11:22:53 +0000 (11:22 +0000)
Make sure the start argument is not negative.

Lib/inspect.py

index 8a58ce9505fec8eb85b6e9aed1c2fd8b42a7dd54..12c9cb757b7f0c72678099b9a49646e70bfa126f 100644 (file)
@@ -756,7 +756,7 @@ def getframeinfo(frame, context=1):
             lines = index = None
         else:
             start = max(start, 1)
-            start = min(start, len(lines) - context)
+            start = max(0, min(start, len(lines) - context))
             lines = lines[start:start+context]
             index = lineno - 1 - start
     else: