summaryrefslogtreecommitdiff
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-07-23 17:10:24 +0300
committerYury Selivanov <yselivanov@sprymix.com>2015-07-23 17:10:24 +0300
commit28cff18dedaf994109a1c4c8f363a076941e1ba3 (patch)
tree5b10c790c279ca73151c3f5a39cf191acc6b5908 /Lib/inspect.py
parent56786c9ea27efb30320f89d663dbff74f5a5e014 (diff)
parent4f4913b38bba5e01fc0e7a26f4840bf342365d3d (diff)
downloadcpython-git-28cff18dedaf994109a1c4c8f363a076941e1ba3.tar.gz
Merge 3.5 (issues #21217, #24485).
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py20
1 files changed, 2 insertions, 18 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 4c1ac1f283..24c8df7225 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -902,14 +902,6 @@ def getblock(lines):
pass
return lines[:blockfinder.last]
-def _line_number_helper(code_obj, lines, lnum):
- """Return a list of source lines and starting line number for a code object.
-
- The arguments must be a code object with lines and lnum from findsource.
- """
- _, end_line = list(dis.findlinestarts(code_obj))[-1]
- return lines[lnum:end_line], lnum + 1
-
def getsourcelines(object):
"""Return a list of source lines and starting line number for an object.
@@ -921,16 +913,8 @@ def getsourcelines(object):
object = unwrap(object)
lines, lnum = findsource(object)
- if ismodule(object):
- return lines, 0
- elif iscode(object):
- return _line_number_helper(object, lines, lnum)
- elif isfunction(object):
- return _line_number_helper(object.__code__, lines, lnum)
- elif ismethod(object):
- return _line_number_helper(object.__func__.__code__, lines, lnum)
- else:
- return getblock(lines[lnum:]), lnum + 1
+ if ismodule(object): return lines, 0
+ else: return getblock(lines[lnum:]), lnum + 1
def getsource(object):
"""Return the text of the source code for an object.