summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/fnmatch.py6
-rw-r--r--Lib/test/test_fnmatch.py5
2 files changed, 10 insertions, 1 deletions
diff --git a/Lib/fnmatch.py b/Lib/fnmatch.py
index b1c37f59df..ffe99b5762 100644
--- a/Lib/fnmatch.py
+++ b/Lib/fnmatch.py
@@ -12,11 +12,15 @@ corresponding to PATTERN. (It does not compile it.)
import re
-__all__ = ["filter", "fnmatch","fnmatchcase","translate"]
+__all__ = ["filter", "fnmatch", "fnmatchcase", "translate"]
_cache = {}
_MAXCACHE = 100
+def _purge():
+ """Clear the pattern cache"""
+ _cache.clear()
+
def fnmatch(name, pat):
"""Test whether FILENAME matches PATTERN.
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py
index 7f0d51d513..37ec50d71a 100644
--- a/Lib/test/test_fnmatch.py
+++ b/Lib/test/test_fnmatch.py
@@ -4,9 +4,14 @@ from test import test_support
import unittest
from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache
+from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache, _purge
class FnmatchTestCase(unittest.TestCase):
+
+ def tearDown(self):
+ _purge()
+
def check_match(self, filename, pattern, should_match=1, fn=fnmatch):
if should_match:
self.assertTrue(fn(filename, pattern),