Issue 1491431: distutils.filelist.glob_to_re fails - Python tracker (original) (raw)

The regex substitution in distutils.filelist.glob_to_re fails to do the right thing in a couple cases:

  1. it fails to translate a dot after an even number of backslashes.

  2. it fails to translate multiple dots in row.

For example:

foo\* -> foo\.*$ foo???? -> foo[^/].[^/].$

The following substitution fixes these problems:

re.sub(r'((?<!\)(\\)*).', r'\1[^/]', re_pattern)

This allows the dot to be preceeded by an even number of backslashes (including 0) and it utilizes a negative look-behind assertion so that adjacent dots are handled.

This problem is present in the svn code, and appears to be identical in versions 2.4.2 and 2.3.5 (the only two versions I had around to check).