Skip to content

Commit 9ce366a

Browse files
committed
Fix distutils.filelist.FileList under Windows (#13193).
The code used to call os.path.join to build a regex but without escaping the backslash, which lead to test failures on Windows. Antoine Pitrou fixed it in 0a94e2f807c7 by enhancing the code to accept both / and \, with proper escaping, but in my opinion this goes against the distutils feature freeze, hence this change.
1 parent 01a2215 commit 9ce366a

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

Lib/distutils/filelist.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,8 @@ def translate_pattern(pattern, anchor=1, prefix=None, is_regex=0):
313313
# ditch end of pattern character
314314
empty_pattern = glob_to_re('')
315315
prefix_re = (glob_to_re(prefix))[:-len(empty_pattern)]
316-
# match both path separators, as in Postel's principle
317-
sep_pat = "[" + re.escape(os.path.sep + os.path.altsep
318-
if os.path.altsep else os.path.sep) + "]"
319-
pattern_re = "^" + sep_pat.join([prefix_re, ".*" + pattern_re])
316+
# paths should always use / in manifest templates
317+
pattern_re = "^%s/.*%s" % (prefix_re, pattern_re)
320318
else: # no prefix -- respect anchor flag
321319
if anchor:
322320
pattern_re = "^" + pattern_re

Misc/NEWS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ Library
282282
- Issues #1745761, #755670, #13357, #12629, #1200313: HTMLParser now correctly
283283
handles non-valid attributes, including adjacent and unquoted attributes.
284284

285-
- Issue #13193: Fix distutils.filelist.FileList under Windows. The
286-
"recursive-include" directive now recognizes both legal path separators.
285+
- Issue #13193: Fix distutils.filelist.FileList under Windows.
287286

288287
- Issue #13384: Remove unnecessary __future__ import in Lib/random.py
289288

0 commit comments

Comments
 (0)