]> granicus.if.org Git - python/commitdiff
Merged revisions 82769 via svnmerge from
authorR. David Murray <rdmurray@bitdance.com>
Sat, 10 Jul 2010 14:11:51 +0000 (14:11 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Sat, 10 Jul 2010 14:11:51 +0000 (14:11 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint

................
  r82769 | r.david.murray | 2010-07-10 10:06:51 -0400 (Sat, 10 Jul 2010) | 15 lines

  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 2.x
  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.
  ........
................

Lib/fnmatch.py
Lib/test/test_fnmatch.py

index b1c37f59dff0cc3cf89e81e60b24e06d496309c1..ffe99b5762db0116b23f3008c7de54d49681a84c 100644 (file)
@@ -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.
 
index 015c580b61ff1a7128f923e8e51037199860a2b6..bd67e05f375d8b280802de62d63c7612913137cf 100644 (file)
@@ -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),