Port the #6884 fix to packaging
diff --git a/Lib/packaging/manifest.py b/Lib/packaging/manifest.py
index 9826d29..40e7330 100644
--- a/Lib/packaging/manifest.py
+++ b/Lib/packaging/manifest.py
@@ -272,6 +272,7 @@
Return True if files are found.
"""
+ # XXX docstring lying about what the special chars are?
files_found = False
pattern_re = _translate_pattern(pattern, anchor, prefix, is_regex)
@@ -335,11 +336,14 @@
# IMHO is wrong -- '?' and '*' aren't supposed to match slash in Unix,
# and by extension they shouldn't match such "special characters" under
# any OS. So change all non-escaped dots in the RE to match any
- # character except the special characters.
- # XXX currently the "special characters" are just slash -- i.e. this is
- # Unix-only.
- pattern_re = re.sub(r'((?<!\\)(\\\\)*)\.', r'\1[^/]', pattern_re)
-
+ # character except the special characters (currently: just os.sep).
+ sep = os.sep
+ if os.sep == '\\':
+ # we're using a regex to manipulate a regex, so we need
+ # to escape the backslash twice
+ sep = r'\\\\'
+ escaped = r'\1[^%s]' % sep
+ pattern_re = re.sub(r'((?<!\\)(\\\\)*)\.', escaped, pattern_re)
return pattern_re
@@ -366,8 +370,10 @@
# ditch end of pattern character
empty_pattern = _glob_to_re('')
prefix_re = _glob_to_re(prefix)[:-len(empty_pattern)]
- # paths should always use / in manifest templates
- pattern_re = "^%s/.*%s" % (prefix_re, pattern_re)
+ sep = os.sep
+ if os.sep == '\\':
+ sep = r'\\'
+ pattern_re = "^" + sep.join((prefix_re, ".*" + pattern_re))
else: # no prefix -- respect anchor flag
if anchor:
pattern_re = "^" + pattern_re