Issue 19658: inspect.getsource weird case (original) (raw)

got:

l = {} import inspect exec(compile('def fun(): pass', '', 'exec'), l, l) inspect.getsource(l['fun']) Traceback (most recent call last): File "", line 1, in 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 "", line 1, in 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