mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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.
This commit is contained in:
parent
a851483527
commit
0425a8ea72
3 changed files with 18 additions and 2 deletions
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue