[Python-bugs-list] [ python-Bugs-449964 ] sre.sub() fails
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 18 Sep 2001 13:47:10 -0700
Bugs item #449964, was opened at 2001-08-10 17:06
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=449964&group_id=5470
Category: Regular Expressions
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Atsuo Ishimoto (atsuoi)
Assigned to: Fredrik Lundh (effbot)
Summary: sre.sub() fails
Initial Comment:
sre.sub() raises exception if template contains
"\g<number>" .
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "c:\tools\python21\lib\sre.py", line 71, in subn
return _compile(pattern, 0).subn(repl, string,
count)
File "c:\tools\python21\lib\sre.py", line 171, in
_subn
template = _compile_repl(template, pattern)
File "c:\tools\python21\lib\sre.py", line 149, in
_compile_repl
p = sre_parse.parse_template(repl, pattern)
File "c:\tools\python21\lib\sre_parse.py", line 701,
in parse_template
this = char(ESCAPES[this][1])
TypeError: object is not callable: '>'
---------------------------------------------------
This patch fix problem.
$ diff -u sre_parse.py.orig sre_parse.py
--- sre_parse.py.orig Sat Aug 11 08:44:11 2001
+++ sre_parse.py Sat Aug 11 08:51:43 2001
@@ -658,12 +658,12 @@
name = ""
if s.match("<"):
while 1:
- char = s.get()
- if char is None:
+ c = s.get()
+ if c is None:
raise
error, "unterminated group name"
- if char == ">":
+ if c == ">":
break
- name = name + char
+ name = name + c
if not name:
raise error, "bad group name"
try:
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=449964&group_id=5470