summaryrefslogtreecommitdiff
path: root/coverage/files.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/files.py')
-rw-r--r--coverage/files.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/coverage/files.py b/coverage/files.py
index d2c2b894..d573f223 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -257,7 +257,9 @@ 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)
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