summaryrefslogtreecommitdiff
path: root/coverage/files.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/files.py')
-rw-r--r--coverage/files.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/coverage/files.py b/coverage/files.py
index d2c2b894..346043da 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -257,13 +257,14 @@ class FnmatchMatcher(object):
# of treating / and \ as equivalent. But on other platforms, we need to
# take care of that ourselves.
fnpats = (fnmatch.translate(p) for p in pats)
- fnpats = (p.replace(r"\/", r"[\\/]") for p in fnpats)
+ # Python3.7 fnmatch translates "/" as "/", before that, it translates as "\/",
+ # so we have to deal with maybe a backslash.
+ fnpats = (re.sub(r"\\?/", r"[\\\\/]", p) for p in fnpats)
+ flags = 0
if env.WINDOWS:
- # Windows is also case-insensitive. BTW: the regex docs say that
- # flags like (?i) have to be at the beginning, but fnmatch puts
- # them at the end, and having two there seems to work fine.
- fnpats = (p + "(?i)" for p in fnpats)
- self.re = re.compile(join_regex(fnpats))
+ # Windows is also case-insensitive, so make the regex case-insensitive.
+ flags |= re.IGNORECASE
+ self.re = re.compile(join_regex(fnpats), flags=flags)
def __repr__(self):
return "<FnmatchMatcher %r>" % self.pats