diff options
author | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-11-01 23:04:26 (GMT) |
---|---|---|
committer | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-11-01 23:04:26 (GMT) |
commit | d6cfb8e0f897c237600859f7c46315c47e42a18b (patch) | |
tree | 1fbd3171ccca3f88344ca87e6c15a16322fce0b3 /Lib/distutils | |
parent | 07728e9b46cdde12b8f16582916b14a89446e275 (diff) | |
download | cpython-d6cfb8e0f897c237600859f7c46315c47e42a18b.zip cpython-d6cfb8e0f897c237600859f7c46315c47e42a18b.tar.gz cpython-d6cfb8e0f897c237600859f7c46315c47e42a18b.tar.bz2 |
reapplied r74493 (after #6665 fix has been backported)
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/filelist.py | 4 | ||||
-rw-r--r-- | Lib/distutils/tests/test_filelist.py | 14 |
2 files changed, 10 insertions, 8 deletions
diff --git a/Lib/distutils/filelist.py b/Lib/distutils/filelist.py index 3ce5635..88b33c7 100644 --- a/Lib/distutils/filelist.py +++ b/Lib/distutils/filelist.py @@ -344,7 +344,9 @@ def translate_pattern (pattern, anchor=1, prefix=None, is_regex=0): pattern_re = '' if prefix is not None: - prefix_re = (glob_to_re(prefix))[0:-1] # ditch trailing $ + # ditch end of pattern character + empty_pattern = glob_to_re('') + prefix_re = (glob_to_re(prefix))[:-len(empty_pattern)] pattern_re = "^" + os.path.join(prefix_re, ".*" + pattern_re) else: # no prefix -- respect anchor flag if anchor: diff --git a/Lib/distutils/tests/test_filelist.py b/Lib/distutils/tests/test_filelist.py index 86db557..1faccfa 100644 --- a/Lib/distutils/tests/test_filelist.py +++ b/Lib/distutils/tests/test_filelist.py @@ -6,15 +6,15 @@ class FileListTestCase(unittest.TestCase): def test_glob_to_re(self): # simple cases - self.assertEquals(glob_to_re('foo*'), 'foo[^/]*$') - self.assertEquals(glob_to_re('foo?'), 'foo[^/]$') - self.assertEquals(glob_to_re('foo??'), 'foo[^/][^/]$') + self.assertEquals(glob_to_re('foo*'), 'foo[^/]*\\Z(?ms)') + self.assertEquals(glob_to_re('foo?'), 'foo[^/]\\Z(?ms)') + self.assertEquals(glob_to_re('foo??'), 'foo[^/][^/]\\Z(?ms)') # special cases - self.assertEquals(glob_to_re(r'foo\\*'), r'foo\\\\[^/]*$') - self.assertEquals(glob_to_re(r'foo\\\*'), r'foo\\\\\\[^/]*$') - self.assertEquals(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]$') - self.assertEquals(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]$') + self.assertEquals(glob_to_re(r'foo\\*'), r'foo\\\\[^/]*\Z(?ms)') + self.assertEquals(glob_to_re(r'foo\\\*'), r'foo\\\\\\[^/]*\Z(?ms)') + self.assertEquals(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]\Z(?ms)') + self.assertEquals(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]\Z(?ms)') def test_suite(): return unittest.makeSuite(FileListTestCase) |