diff options
author | Vladimir Matveev <v2matveev@outlook.com> | 2018-08-24 14:18:00 (GMT) |
---|---|---|
committer | Tal Einat <taleinat+github@gmail.com> | 2018-08-24 14:18:00 (GMT) |
commit | 91cb298f811961277fd4cc4a32211899d48bedcb (patch) | |
tree | 6b833e01b19fdae681b767cc44f4b8d3e676e88a /Lib/inspect.py | |
parent | 075b3c325913475be16650f7cb2a99f3136623b9 (diff) | |
download | cpython-91cb298f811961277fd4cc4a32211899d48bedcb.zip cpython-91cb298f811961277fd4cc4a32211899d48bedcb.tar.gz cpython-91cb298f811961277fd4cc4a32211899d48bedcb.tar.bz2 |
bpo-6700: Fix inspect.getsourcelines for module level frames/tracebacks (GH-8864)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 7175186..e799a83 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -954,7 +954,12 @@ def getsourcelines(object): object = unwrap(object) lines, lnum = findsource(object) - if ismodule(object): + if istraceback(object): + object = object.tb_frame + + # for module or frame that corresponds to module, return all source lines + if (ismodule(object) or + (isframe(object) and object.f_code.co_name == "<module>")): return lines, 0 else: return getblock(lines[lnum:]), lnum + 1 |