Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions python-stdlib/fnmatch/fnmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def normcase(s):

__all__ = ["filter", "fnmatch", "fnmatchcase", "translate"]

COMPAT = re.__name__ == "ure"


def fnmatch(name, pat):
"""Test whether FILENAME matches PATTERN.
Expand Down Expand Up @@ -58,12 +56,18 @@ def _compile_pattern(pat):
res = bytes(res_str, "ISO-8859-1")
else:
res = translate(pat)
if COMPAT:

try:
ptn = re.compile(res)
except ValueError:
# re1.5 doesn't support all regex features
if res.startswith("(?ms)"):
res = res[5:]
if res.endswith("\\Z"):
res = res[:-2] + "$"
return re.compile(res).match
ptn = re.compile(res)

return ptn.match


def filter(names, pat):
Expand Down
2 changes: 1 addition & 1 deletion python-stdlib/fnmatch/manifest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
metadata(version="0.6.0")
metadata(version="0.6.1")

module("fnmatch.py")