[Python-checkins] r82769 - in python/branches/release27-maint: Lib/fnmatch.py Lib/test/test_fnmatch.py

r.david.murray python-checkins at python.org
Sat Jul 10 16:06:51 CEST 2010


Author: r.david.murray
Date: Sat Jul 10 16:06:51 2010
New Revision: 82769

Log:
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.
........


Modified:
   python/branches/release27-maint/   (props changed)
   python/branches/release27-maint/Lib/fnmatch.py
   python/branches/release27-maint/Lib/test/test_fnmatch.py

Modified: python/branches/release27-maint/Lib/fnmatch.py
==============================================================================
--- python/branches/release27-maint/Lib/fnmatch.py	(original)
+++ python/branches/release27-maint/Lib/fnmatch.py	Sat Jul 10 16:06:51 2010
@@ -12,11 +12,15 @@
 
 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.
 

Modified: python/branches/release27-maint/Lib/test/test_fnmatch.py
==============================================================================
--- python/branches/release27-maint/Lib/test/test_fnmatch.py	(original)
+++ python/branches/release27-maint/Lib/test/test_fnmatch.py	Sat Jul 10 16:06:51 2010
@@ -4,9 +4,14 @@
 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),


More information about the Python-checkins mailing list