SF #737473: Show up-to-date source code in tracebacks always.

And add an optional argument 'filename' to linecache.checkcache()
to enable checking caches per-file.
This commit is contained in:
Hye-Shik Chang 2004-10-26 09:16:42 +00:00
parent 23109ef11e
commit 182ac85147
5 changed files with 60 additions and 4 deletions

View file

@ -40,11 +40,19 @@ def getlines(filename):
return updatecache(filename)
def checkcache():
def checkcache(filename=None):
"""Discard cache entries that are out of date.
(This is not checked upon each call!)"""
for filename in cache.keys():
if filename is None:
filenames = cache.keys()
else:
if filename in cache:
filenames = [filename]
else:
return
for filename in filenames:
size, mtime, lines, fullname = cache[filename]
try:
stat = os.stat(fullname)