New submission from Ronny Pfannschmidt: got: >>> l = {} >>> import inspect >>> exec(compile('def fun(): pass', '', 'exec'), l, l) >>> inspect.getsource(l['fun']) Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/private/.local/lib/python3.3/inspect.py", line 726, in getsource lines, lnum = getsourcelines(object) File "/home/private/.local/lib/python3.3/inspect.py", line 715, in getsourcelines lines, lnum = findsource(object) File "/home/private/.local/lib/python3.3/inspect.py", line 553, in findsource if not sourcefile and file[0] + file[-1] != '<>': IndexError: string index out of range
expected: >>> l = {} >>> import inspect >>> exec(compile('def fun(): pass', '', 'exec'), l, l) >>> inspect.getsource(l['fun']) Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/private/.local/lib/python3.3/inspect.py", line 726, in getsource lines, lnum = getsourcelines(object) File "/home/private/.local/lib/python3.3/inspect.py", line 715, in getsourcelines lines, lnum = findsource(object) File "/home/private/.local/lib/python3.3/inspect.py", line 563, in findsource raise IOError('could not get source code') OSError: could not get source code this is a extraction, it appears that python in certein circumstances creates code objects with that setup on its own, im still further investigating ---------- messages: 203426 nosy: Ronny.Pfannschmidt priority: normal severity: normal status: open title: inspect.getsource weird case type: behavior versions: Python 2.7, Python 3.2, Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19658> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com