This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author theller
Recipients
Date 2005-09-30.14:57:17
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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.

So, if the traceback's stack contains an entry for a
non-existing file (for example because the .py file for
a .pyc file is no longer present), linecache returns
absolute garbage.

Example, on my system (the \a\b\c\__init__.py file
doesn't exist):

C:\>python -c "import linecache; print
linecache.getlines(r'\a\b\c\__init__.py')"
['#\n', '# The Python Imaging Library.\n',
'# $Id: //modules/pil/PIL/__init__.py#2 $\n', '#\n',
'# package placeholder\n', '#\n', '# Copyright (c) 1999
by Secret Labs AB.\n',
'#\n', '# See the README file for information on usage
and redistribution.\n',
'#\n', '\n', '# ;-)\n']
C:\>

The bug is present in 2.3, 2.4, and current CVS.
History
Date User Action Args
2007-08-23 14:35:02adminlinkissue1309567 messages
2007-08-23 14:35:02admincreate