diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-07-10 13:52:13 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-07-10 13:52:13 (GMT) |
commit | 0425a8ea729617a74ab343909687d98216d25524 (patch) | |
tree | 40bf391a27838e4c86970262d485e834b36d50b1 /Lib/fnmatch.py | |
parent | a85148352773929e11324f3786ebe5a78f372d94 (diff) | |
download | cpython-0425a8ea729617a74ab343909687d98216d25524.zip cpython-0425a8ea729617a74ab343909687d98216d25524.tar.gz cpython-0425a8ea729617a74ab343909687d98216d25524.tar.bz2 |
Fix 'refleak' introduced by fnmatch cache purge tests.
This introduces a 'purge' function for the fnmatch module analogous
to the 'purge' function in the re module.
Diffstat (limited to 'Lib/fnmatch.py')
-rw-r--r-- | Lib/fnmatch.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/fnmatch.py b/Lib/fnmatch.py index 26ae4cc..aa682bb 100644 --- a/Lib/fnmatch.py +++ b/Lib/fnmatch.py @@ -12,12 +12,17 @@ corresponding to PATTERN. (It does not compile it.) import re -__all__ = ["filter", "fnmatch","fnmatchcase","translate"] +__all__ = ["filter", "fnmatch", "fnmatchcase", "purge", "translate"] _cache = {} # Maps text patterns to compiled regexen. _cacheb = {} # Ditto for bytes patterns. _MAXCACHE = 100 # Maximum size of caches +def purge(): + """Clear the pattern cache""" + _cache.clear() + _cacheb.clear() + def fnmatch(name, pat): """Test whether FILENAME matches PATTERN. |