summaryrefslogtreecommitdiffstats
path: root/Lib/linecache.py
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2004-10-26 09:16:42 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2004-10-26 09:16:42 (GMT)
commit182ac8514726402451a90fd59c9bf427f8071365 (patch)
tree1e7d6a1c24390a303d69842271d0a96cabefba7b /Lib/linecache.py
parent23109ef11e91c49b56b517ce454bcf87a4153c62 (diff)
downloadcpython-182ac8514726402451a90fd59c9bf427f8071365.zip
cpython-182ac8514726402451a90fd59c9bf427f8071365.tar.gz
cpython-182ac8514726402451a90fd59c9bf427f8071365.tar.bz2
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.
Diffstat (limited to 'Lib/linecache.py')
-rw-r--r--Lib/linecache.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/linecache.py b/Lib/linecache.py
index 1b70c7c..2ccc6c6 100644
--- a/Lib/linecache.py
+++ b/Lib/linecache.py
@@ -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)