Index: fnmatch.py =================================================================== --- fnmatch.py (revision 77948) +++ fnmatch.py (working copy) @@ -15,6 +15,7 @@ __all__ = ["filter", "fnmatch","fnmatchcase","translate"] _cache = {} +_MAXCACHE = 100 def fnmatch(name, pat): """Test whether FILENAME matches PATTERN. @@ -44,6 +45,8 @@ pat=os.path.normcase(pat) if not pat in _cache: res = translate(pat) + if len(_cache) >= _MAXCACHE: + _cache.clear() _cache[pat] = re.compile(res) match=_cache[pat].match if os.path is posixpath: @@ -66,6 +69,8 @@ if not pat in _cache: res = translate(pat) + if len(_cache) >= _MAXCACHE: + _cache.clear() _cache[pat] = re.compile(res) return _cache[pat].match(name) is not None