Kaydet (Commit) 46d9fda0 authored tarafından Fred Drake's avatar Fred Drake

Donovan Baarda <abo@users.sourceforge.net>:

Patch to make "\" in a character group work properly.

This closes SF bug #409651.
üst 22710823
...@@ -75,17 +75,13 @@ def translate(pat): ...@@ -75,17 +75,13 @@ def translate(pat):
if j >= n: if j >= n:
res = res + '\\[' res = res + '\\['
else: else:
stuff = pat[i:j] stuff = pat[i:j].replace('\\','\\\\')
i = j+1 i = j+1
if stuff[0] == '!': if stuff[0] == '!':
stuff = '[^' + stuff[1:] + ']' stuff = '^' + stuff[1:]
elif stuff == '^'*len(stuff): elif stuff[0] == '^':
stuff = '\\^' stuff = '\\' + stuff
else: res = '%s[%s]' % (res, stuff)
while stuff[0] == '^':
stuff = stuff[1:] + stuff[0]
stuff = '[' + stuff + ']'
res = res + stuff
else: else:
res = res + re.escape(c) res = res + re.escape(c)
return res + "$" return res + "$"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment