File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 1414
1515__all__ = ["filter" , "fnmatch" ,"fnmatchcase" ,"translate" ]
1616
17- _cache = {}
17+ _cache = {} # Maps text patterns to compiled regexen.
18+ _cacheb = {} # Ditto for bytes patterns.
1819
1920def fnmatch (name , pat ):
2021 """Test whether FILENAME matches PATTERN.
@@ -38,15 +39,16 @@ def fnmatch(name, pat):
3839 return fnmatchcase (name , pat )
3940
4041def _compile_pattern (pat ):
41- regex = _cache .get (pat )
42+ cache = _cacheb if isinstance (pat , bytes ) else _cache
43+ regex = cache .get (pat )
4244 if regex is None :
4345 if isinstance (pat , bytes ):
4446 pat_str = str (pat , 'ISO-8859-1' )
4547 res_str = translate (pat_str )
4648 res = bytes (res_str , 'ISO-8859-1' )
4749 else :
4850 res = translate (pat )
49- _cache [pat ] = regex = re .compile (res )
51+ cache [pat ] = regex = re .compile (res )
5052 return regex .match
5153
5254def filter (names , pat ):
You can’t perform that action at this time.
0 commit comments