diff options
author | Fred Drake <fdrake@acm.org> | 2001-03-21 18:05:48 +0000 |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-03-21 18:05:48 +0000 |
commit | 46d9fda0080bb818a37e63e1156949a11f8f80e8 (patch) | |
tree | 33c5a53081e93c5c88cb3392a96b214ecc7895d9 /Lib/fnmatch.py | |
parent | 22710823fb554a796dc96c44885d7a9389426824 (diff) | |
download | cpython-git-46d9fda0080bb818a37e63e1156949a11f8f80e8.tar.gz |
Donovan Baarda <abo@users.sourceforge.net>:
Patch to make "\" in a character group work properly.
This closes SF bug #409651.
Diffstat (limited to 'Lib/fnmatch.py')
-rw-r--r-- | Lib/fnmatch.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Lib/fnmatch.py b/Lib/fnmatch.py index c40f50035d..182a9ef923 100644 --- a/Lib/fnmatch.py +++ b/Lib/fnmatch.py @@ -75,17 +75,13 @@ def translate(pat): if j >= n: res = res + '\\[' else: - stuff = pat[i:j] + stuff = pat[i:j].replace('\\','\\\\') i = j+1 if stuff[0] == '!': - stuff = '[^' + stuff[1:] + ']' - elif stuff == '^'*len(stuff): - stuff = '\\^' - else: - while stuff[0] == '^': - stuff = stuff[1:] + stuff[0] - stuff = '[' + stuff + ']' - res = res + stuff + stuff = '^' + stuff[1:] + elif stuff[0] == '^': + stuff = '\\' + stuff + res = '%s[%s]' % (res, stuff) else: res = res + re.escape(c) return res + "$" |