You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From some hacking, I've found that the root cause appears to be that
linecache.getlines() returns a number of lines that do not match the
actual file. (In my case, getlines() returns 405 lines when
distutils/cmd.py has 478 lines.)
This bug causes pydoc to break when it is pointed at distutils.cmd.
This is on Ubuntu Gutsy, Python 2.5.1
draghuram commented on Jan 3, 2008
draghurammannequin
Mannequin
More actions
I can't reproduce it with 2.5.1 on SuSE 10. Can you please report the
exact traceback you see?
AstraLuma commented on Jan 3, 2008
AstraLumamannequin
MannequinAuthor
More actions
sqlite3/test/types.py also seems to cause the same error, although the
difference is much wider (101 lines vs. 351).
AstraLuma commented on Jan 3, 2008
AstraLumamannequin
MannequinAuthor
More actions
The exact traceback is as follows:
>>> findsource(distutils.cmd.install_misc.get_outputs)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/inspect.py", line 510, in findsource
if pat.match(lines[lnum]): break
IndexError: list index out of range
I strongly suspect that this is because somehow linecache finds a
different version of the module on sys.path.
AstraLuma commented on Jan 3, 2008
AstraLumamannequin
MannequinAuthor
More actions
Indeed. For the distutils.cmd case, linecache.updatecache() takes
"cmd.py" and tracks that down to /usr/lib/python2.5/cmd.py. This would
also explain the sqlite3.tests.types problem.
The bug seems to be that the inspect module doesn't pass enough context
information to linecache to unambiguously locate the file.
Can you trace this a bit further? Can you suggest a specific
modification that would fix this issue?
draghuram commented on Jan 3, 2008
draghurammannequin
Mannequin
More actions
When I printed the file name that is being passed to
linecache.getlines() by findsource(), the file name is absolute path.
So there may be nothing wrong with linecache itself. Can you see what
is the name being passed in your case? We still need to trace what
specific setting on OP's system is causing the problem.
AstraLuma commented on Jan 3, 2008
AstraLumamannequin
MannequinAuthor
More actions
depending on the use case, updatecache() will be passed
'distutils/cmd.py', but still turn that into '/usr/lib/python2.5/cmd.py'.
I have not messed with my stock Python modules. My sys.path is:
I've also attached the script I used to discover the bug originally.
(Much larger than the snippets I've been pasting here.) Just be warned
that it writes a large number of files and produces considerable output.
Activity
AstraLuma commentedon Jan 3, 2008
Something about distutils/cmd.py breaks inspect.findsource(). I am
unsure if this is a bug with DistUtils or the inspect module.
Causes findsource() to receive an IndexError.
From some hacking, I've found that the root cause appears to be that
linecache.getlines() returns a number of lines that do not match the
actual file. (In my case, getlines() returns 405 lines when
distutils/cmd.py has 478 lines.)
This bug causes pydoc to break when it is pointed at distutils.cmd.
This is on Ubuntu Gutsy, Python 2.5.1
draghuram commentedon Jan 3, 2008
I can't reproduce it with 2.5.1 on SuSE 10. Can you please report the
exact traceback you see?
AstraLuma commentedon Jan 3, 2008
sqlite3/test/types.py also seems to cause the same error, although the
difference is much wider (101 lines vs. 351).
AstraLuma commentedon Jan 3, 2008
The exact traceback is as follows:
>>> findsource(distutils.cmd.install_misc.get_outputs) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/inspect.py", line 510, in findsource if pat.match(lines[lnum]): break IndexError: list index out of rangegvanrossum commentedon Jan 3, 2008
Can't repro either.
I strongly suspect that this is because somehow linecache finds a
different version of the module on sys.path.
AstraLuma commentedon Jan 3, 2008
Indeed. For the distutils.cmd case, linecache.updatecache() takes
"cmd.py" and tracks that down to /usr/lib/python2.5/cmd.py. This would
also explain the sqlite3.tests.types problem.
The bug seems to be that the inspect module doesn't pass enough context
information to linecache to unambiguously locate the file.
gvanrossum commentedon Jan 3, 2008
Can you trace this a bit further? Can you suggest a specific
modification that would fix this issue?
draghuram commentedon Jan 3, 2008
When I printed the file name that is being passed to
linecache.getlines() by findsource(), the file name is absolute path.
So there may be nothing wrong with linecache itself. Can you see what
is the name being passed in your case? We still need to trace what
specific setting on OP's system is causing the problem.
AstraLuma commentedon Jan 3, 2008
depending on the use case, updatecache() will be passed
'distutils/cmd.py', but still turn that into '/usr/lib/python2.5/cmd.py'.
I have not messed with my stock Python modules. My sys.path is:
I've also attached the script I used to discover the bug originally.
(Much larger than the snippets I've been pasting here.) Just be warned
that it writes a large number of files and produces considerable output.
tiran commentedon Jan 3, 2008
The issue is probably related to http://bugs.python.org/issue1665
gvanrossum commentedon Jan 3, 2008
Do you happen to be on Ubuntu?
Maybe this is the same as issue bpo-1665 ?
AstraLuma commentedon Jan 4, 2008
They might be the same bug, with different manifestations.
That bug is starting to get rather annoying.
(At first, I thought it wasn't. Surprise, surprise.)