summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-06-25 17:21:04 +0200
committerRaymond Hettinger <python@rcn.com>2011-06-25 17:21:04 +0200
commitd0de3d4cc458b986bce870a5f57b8fe878f370e2 (patch)
tree9500bf6d228ec8efec63cb3267c7ff4821e0d080 /Lib
parent142d0f5e5a11339d74c105668fe394b2d90e20d6 (diff)
parent70797194ab678d53bb1c24536354aa1acc4db467 (diff)
downloadcpython-git-d0de3d4cc458b986bce870a5f57b8fe878f370e2.tar.gz
Issue 11802: filecmp cache was growing without bound.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/filecmp.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/filecmp.py b/Lib/filecmp.py
index e5983cd776..f5cea1de6f 100644
--- a/Lib/filecmp.py
+++ b/Lib/filecmp.py
@@ -48,11 +48,12 @@ def cmp(f1, f2, shallow=True):
if s1[1] != s2[1]:
return False
- result = _cache.get((f1, f2))
- if result and (s1, s2) == result[:2]:
- return result[2]
- outcome = _do_cmp(f1, f2)
- _cache[f1, f2] = s1, s2, outcome
+ outcome = _cache.get((f1, f2, s1, s2))
+ if outcome is None:
+ outcome = _do_cmp(f1, f2)
+ if len(_cache) > 100: # limit the maximum size of the cache
+ _cache.clear()
+ _cache[f1, f2, s1, s2] = outcome
return outcome
def _sig(st):