mirror of
https://github.com/python/cpython.git
synced 2024-11-25 02:44:06 +08:00
Donovan Baarda <abo@users.sourceforge.net>:
Patch to make "\" in a character group work properly. This closes SF bug #409651.
This commit is contained in:
parent
22710823fb
commit
46d9fda008
@ -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 + "$"
|
||||
|
Loading…
Reference in New Issue
Block a user