From fcfea15a10dbe010a8fd8fcd7b8ac1c37ae19678 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 5 Oct 2017 07:57:16 -0400 Subject: Python3.7 removed an unneeded backslash from fnmatch.translate --- coverage/files.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'coverage/files.py') 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 -- cgit v1.2.1