This appears to be a long-standing problem in the standard linecache
module. It doesn't handle packages correctly. In the updatecache
function, line 82 does this:

basename = os.path.split(filename)[1]

In my example, filename is 'logging/__init__.py', so basename becomes
'__init__.py'. Later, updatecache iterates through sys.path joining
basename to each entry, calls os.stat on the result to see if it is
valid, and accepts the first valid file it finds. sys.path contains '.',
so the first valid file is './__init__.py' -- obviously not the source
file it was looking for.

The attached patch checks for basename == '__init__.py' and uses the
passed-in filename instead. For a package, that should give the relative
path to the __init__.py file from a location is sys.path.

** Attachment added: "Proper handling of packages in linecache"
   http://launchpadlibrarian.net/8483418/linecache.py.patch

-- 
pydoc logging traceback
https://bugs.launchpad.net/bugs/70902
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to