@@ -35,9 +35,9 @@ def fnmatch(name, pat):
3535 pat = os .path .normcase (pat )
3636 return fnmatchcase (name , pat )
3737
38- @functools .lru_cache (maxsize = 250 )
39- def _compile_pattern (pat , is_bytes = False ):
40- if is_bytes :
38+ @functools .lru_cache (maxsize = 250 , typed = True )
39+ def _compile_pattern (pat ):
40+ if isinstance ( pat , bytes ) :
4141 pat_str = str (pat , 'ISO-8859-1' )
4242 res_str = translate (pat_str )
4343 res = bytes (res_str , 'ISO-8859-1' )
@@ -49,7 +49,7 @@ def filter(names, pat):
4949 """Return the subset of the list NAMES that match PAT."""
5050 result = []
5151 pat = os .path .normcase (pat )
52- match = _compile_pattern (pat , isinstance ( pat , bytes ) )
52+ match = _compile_pattern (pat )
5353 if os .path is posixpath :
5454 # normcase on posix is NOP. Optimize it away from the loop.
5555 for name in names :
@@ -67,7 +67,7 @@ def fnmatchcase(name, pat):
6767 This is a version of fnmatch() which doesn't case-normalize
6868 its arguments.
6969 """
70- match = _compile_pattern (pat , isinstance ( pat , bytes ) )
70+ match = _compile_pattern (pat )
7171 return match (name ) is not None
7272
7373
0 commit comments