New submission from Gabriel Genellina <gagsl-...@yahoo.com.ar>: inspect.getsource(obj) returns incorrect results when obj is a traceback or frame object outside any function (that is, at the module level).
This demo script shows the problem. The correct output should contain all source lines in the module, but it only returns the first two: D:\temp>type show_inspect_bug.py def foo(x): return y + z import inspect frame = inspect.currentframe() print inspect.getsource(frame) D:\temp>python show_inspect_bug.py def foo(x): return y + z The attached patch fixes the problem and adds some missing test cases. Originally reported by Juanjo Conti at the local Python group. ---------- components: Library (Lib) files: inspect.diff keywords: patch messages: 91541 nosy: gagenellina severity: normal status: open title: inspect.getsource() returns incorrect source lines type: behavior versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2 Added file: http://bugs.python.org/file14716/inspect.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6700> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com