mirror of
https://github.com/python/cpython
synced 2024-09-19 23:41:48 +00:00
Fix bug #570057: Broken pre.subn() (and pre.sub())
This should be backported to the 2.2.X series (how do I do that?)
This commit is contained in:
parent
1add023b88
commit
6f7c3431c8
|
@ -367,10 +367,12 @@ def subn(self, repl, source, count=0):
|
|||
end = len(source)
|
||||
|
||||
if type(repl) is type(''):
|
||||
# See if repl contains group references
|
||||
# See if repl contains group references (if it does,
|
||||
# pcre_expand will attempt to call _Dummy.group, which
|
||||
# results in a TypeError)
|
||||
try:
|
||||
repl = pcre_expand(_Dummy, repl)
|
||||
except error:
|
||||
except (error, TypeError):
|
||||
m = MatchObject(self, source, 0, end, [])
|
||||
repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue