summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 2b25300..1731456 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -970,10 +970,12 @@ def findsource(object):
if isclass(object):
try:
- firstlineno = vars(object)['__firstlineno__']
+ lnum = vars(object)['__firstlineno__'] - 1
except (TypeError, KeyError):
raise OSError('source code not available')
- return lines, firstlineno - 1
+ if lnum >= len(lines):
+ raise OSError('lineno is out of bounds')
+ return lines, lnum
if ismethod(object):
object = object.__func__