summaryrefslogtreecommitdiffstats
path: root/Lib/fnmatch.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-07-10 14:00:10 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-07-10 14:00:10 (GMT)
commitca126a02ea71aa55de59c12bdd99ec2f7cb6d89d (patch)
tree6a2dbe74dc781649a98f34231f4f38444ce3fa38 /Lib/fnmatch.py
parentee3396901c0045632a36df676efc2d85e95d5f06 (diff)
downloadcpython-ca126a02ea71aa55de59c12bdd99ec2f7cb6d89d.zip
cpython-ca126a02ea71aa55de59c12bdd99ec2f7cb6d89d.tar.gz
cpython-ca126a02ea71aa55de59c12bdd99ec2f7cb6d89d.tar.bz2
Merged revisions 82766 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k Since 'purge' is an API change, modified it to be _purge for 3.1 and deleted the doc update. ........ r82766 | r.david.murray | 2010-07-10 09:52:13 -0400 (Sat, 10 Jul 2010) | 5 lines 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.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/fnmatch.py b/Lib/fnmatch.py
index 26ae4cc..be1fd1d 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", "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.