8000 Undo modifications to fnmatch.py · python/cpython@0afcd54 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0afcd54

Browse files
committed
Undo modifications to fnmatch.py
1 parent b5c002e commit 0afcd54

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

Lib/fnmatch.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ def translate(pat):
7777
There is no way to quote meta-characters.
7878
"""
7979

80-
res = _translate(pat)
81-
return fr'(?s:{res})\Z'
82-
83-
84-
def _translate(pat):
8580
STAR = object()
8681
res = []
8782
add = res.append
@@ -187,4 +182,4 @@ def _translate(pat):
187182
add(f"(?>.*?{fixed})")
188183
assert i == n
189184
res = "".join(res)
190-
return res
185+
return fr'(?s:{res})\Z'

Lib/pathlib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def _is_wildcard_pattern(pat):
6666

6767

6868
_SWAP_SLASH_AND_NEWLINE = str.maketrans({'/': '\n', '\n': '/'})
69+
_FNMATCH_PADDING = fnmatch.translate('_').split('_')
70+
_FNMATCH_SLICE = slice(len(_FNMATCH_PADDING[0]), -len(_FNMATCH_PADDING[1]))
6971

7072

7173
@functools.lru_cache()
@@ -77,7 +79,7 @@ def _translate(pattern):
7779
elif '**' in pattern:
7880
raise ValueError("Invalid pattern: '**' can only be an entire path component")
7981
else:
80-
return fnmatch._translate(pattern)
82+
return fnmatch.translate(pattern)[_FNMATCH_SLICE]
8183

8284

8385
@functools.lru_cache()

0 commit comments

Comments
 (0)
0