Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e45a7f6

Browse files
pi-anldpgeorge
authored andcommitted
fnmatch: Fix compatibility with ure -> re.
With the recent MicroPython change to remove the u prefix by default on builtins (micropython/micropython#11740) the format checker in fnmatch which was detecting ure no longer works. This commit updates the module to filter the regex automatically as needed. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent 6103823 commit e45a7f6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

‎python-stdlib/fnmatch/fnmatch.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ def normcase(s):
2727

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

30-
COMPAT = re.__name__ == "ure"
31-
3230

3331
def fnmatch(name, pat):
3432
"""Test whether FILENAME matches PATTERN.
@@ -58,12 +56,18 @@ def _compile_pattern(pat):
5856
res = bytes(res_str, "ISO-8859-1")
5957
else:
6058
res = translate(pat)
61-
if COMPAT:
59+
60+
try:
61+
ptn = re.compile(res)
62+
except ValueError:
63+
# re1.5 doesn't support all regex features
6264
if res.startswith("(?ms)"):
6365
res = res[5:]
6466
if res.endswith("\\Z"):
6567
res = res[:-2] + "$"
66-
return re.compile(res).match
68+
ptn = re.compile(res)
69+
70+
return ptn.match
6771

6872

6973
def filter(names, pat):

‎python-stdlib/fnmatch/manifest.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.6.0")
1+
metadata(version="0.6.1")
22

33
module("fnmatch.py")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /