[Python-Dev] linecache problem (original) (raw)
Thomas Heller theller at python.net
Fri Sep 30 16:59:11 CEST 2005
- Previous message: [Python-Dev] linecache problem
- Next message: [Python-Dev] bool(container) [was bool(iter([])) changed between 2.3 and 2.4]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum <guido at python.org> writes:
On 9/30/05, Thomas Heller <theller at python.net> wrote:
On several occasions I have seen tracebacks in my code pointing to PIL's init.py file. That is strange, because I have installed PIL but it is used nowhere.
Finally I traced it down to a problem in the linecache code, which tries to be smart in up updatecache function. When os.stat() on the filename fails with os.error, it walks along sys.path and returns the first file with a matching basename. This may make sense for toplevel modules, but never for modules in packages.
The bug is present in 2.3, 2.4, and current CVS. Probably my fault (I wrote linecache, 13 years ago (before Python had packages!). But looking at the code I don't understand why this is; there's no code to descend into subdirectories of directories found on sys.path. I wonder if the problem isn't on PIL's end, which puts the PIL directory on sys.path?
It seems PIL cannot decide if it wants to be a package or not, but better would be to ask the author. /F, ?
It installs a PIL.pth file in lib/site-packages, which contains 'PIL' only - that's where the sys.path entry comes from. OTOH, the lib/site-packages/PIL directory contains an init.py file. PIL.pth is the only .pth file that I have where the directory contains an init.py file.
Anyway, don't hesitate to suggest a patch on sourceforge -- python-dev really isn't the forum for further discussion of this issue.
https://sourceforge.net/tracker/index.php?func=detail&aid=1309567&group_id=5470&atid=105470
Thomas
- Previous message: [Python-Dev] linecache problem
- Next message: [Python-Dev] bool(container) [was bool(iter([])) changed between 2.3 and 2.4]
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]