linecache vs egg - reading line of a file in an egg
rocky at panix.com
Sun Dec 21 04:18:44 CET 2008
Does linecache work with source in Python eggs? If not, is it
contemplated that this is going to be fixed or is there something else
like linecache that currently works?
Right now, I think pdb and pydb (and probably other debuggers) are
broken when they try to trace into code that is part of an egg.
Here's what I tried recently:
Using this egg:
I install that and look for the filename of one of the
functions. Here's a sample session:
>>> import tracer
<module 'tracer' from '/usr/lib/python2.5/site-packages/tracer-0.1.0-py2.5.egg/tracer.pyc'>
<function size at 0xb7c39a74>
To read the source for tracer.py, information from "Accessing Package
>>> from pkg_resources import resource_string
>>> print resource_string('tracer', 'tracer.py')
This gives me one long string which I can split and then index.
Note that I used "tracer.py" above, not
"build/bdist.linux-8686/egg/tracer.py" How do tracebacks and things that
read frame information deal with the discrepency?
Before reinventing the wheel and trying to extend linecache to do
something like the above, has someone already come up with a solution?
More information about the Python-list