[New-bugs-announce] [issue19658] inspect.getsource weird case
Ronny Pfannschmidt
report at bugs.python.org
Tue Nov 19 22:25:43 CET 2013
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 <report at bugs.python.org>
<http://bugs.python.org/issue19658>
_______________________________________
More information about the New-bugs-announce
mailing list